Can somebody tell me what are the latest Rich UI development framework/technologies available in Microsoft ASP.NET MVC?

Ex:- To develop a shopping cart website Customer attraction, flexibility and usability are the primary requirements to select the technology.

My user is authenticated using OWIN authentication and this user needs to download a file from a folder located on another Server using his current OWIN authentication without passing his username and password again. My questions are: 1- Is this possible? 2- Is there any security breach in this approach?

I am using entity framework and taking my datas from database and fill my gridview with them.Datas selected by user from a treview.Simply, user selects a data from treeview and I put it to gridview. Lastly I have a button for clearing the gridview. Here is my aspx:

<div id="divPrint" style="background-color: white" runat="server">
   <asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
       <p style="text-align:center">HDCVI KAMERA FİYAT TEKLİFİDİR</p>
         <asp:GridView ID="GridViewHdcvi" runat="server" DataSourceID="EntityDataSourceHdcvi" AutoGenerateColumns="False">
          <Columns>
          <asp:TemplateField HeaderText="ÜRÜN VE DETAYLARI">
          <ItemStyle Width="400px" />
          <ItemTemplate>
          <div style="color: red" class="text-center"><%#Eval("UrunAdi") %></div>
          <%#Eval("UrunDetay") %>
          </ItemTemplate>
          </asp:TemplateField>
          <asp:ImageField HeaderText="ÜRÜN GÖRSELİ" DataImageUrlField="UrunResim"></asp:ImageField>
           <asp:TemplateField HeaderText="BİRİM FİYAT">
           <ItemTemplate>
           <%#Eval("UrunFiyati") %>
            </ItemTemplate>
            </asp:TemplateField>
           <asp:TemplateField HeaderText="ADET">
              <ItemTemplate>
    <asp:TextBox ID="txtAdet" runat="server" Width="40px"></asp:TextBox>
           </ItemTemplate>
          </asp:TemplateField>
           </Columns>
          </asp:GridView>
          </ContentTemplate>
           </asp:UpdatePanel>
         </div>
<asp:Button ID="btnListiSifirla" runat="server" Text="Listeyi Sıfırla" CssClass="btn btn-danger" OnClick="btnListiSifirla_Click" />

And my codebehind:

 static List<string> urunList = new List<string>();

    protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        string id = TreeView1.SelectedValue;
        urunList.Add(id); 
        listeyiDoldur();
    }

    protected void listeyiDoldur() 
    {
        if (urunList.Count == 0)
        {
            failDiv.Visible = true;
        }
        else
        {
            string query = "SELECT UrunTable.UrunAdi, UrunTable.UrunFiyati, UrunTable.UrunResim, UrunTable.UrunKategori, UrunTable.UrunDetay FROM UrunTable WHERE ";
            foreach (var val in urunList)
            {
                if (val.Equals(urunList[urunList.Count - 1]))
                {
                    query += "UrunTable.UrunId = " + val;
                }
                else
                {
                    query += "UrunTable.UrunId = " + val + " || ";
                }
            }
            EntityDataSourceHdcvi.CommandText = query;
            divPrint.Visible = true;
            btnListiSifirla.Visible = true;
        }
    }

    protected void btnListiSifirla_Click(object sender, EventArgs e)
    {
        urunList.Clear();
        btnListiSifirla.Visible = false;
        Page_Load(null,EventArgs.Empty);
    }

I can successfully display selected datas in gridview and clear them when button is pressed. Here is the problem: After clearing the gridview I can't add the last added item again.For example if I add item1,item2 and item3 in this order,after clearing the gridview I can't add item3. I can add item1 or item2, then item3. I can't add item firstly which I added last before clearing. I tried clearing gridview in button's onClick and tried other lots of things but nothing gave any result. Thanks for your time.

I recently updated the JQuery library of one of my projects from 2.1.3 to 2.1.4 vis NuGet package manager. But when i run the web app, it tries to reference JQuery 2.1.3 instead of JQuery 2.1.4. The default bundling config is not changed..

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
               "~/Scripts/jquery-{version}.js"));

            . . . 
}

IS there some kind of a cache happening. How can i get to reference JQuery 2.1.4.

I have a problem in setting the width of the element both at server and client side. At client side the css is not overriding the applied css from server side. All I need to do is add css to td at server side, and client side remove the old css and apply the new css.

Here is my code

Design Page

 <td id="tdlblOverRideText" runat="server">
         <asp:Label ID="lblOverRideText" Text="Overridden charges are denoted by green background" runat ="server" Visible ="false" BackColor="#efffff"></asp:Label>    
     </td>

Server side:

tdlblOverRideText.Attributes.Add("class", "OverRideText");

Clientside:

    $("#tdlblOverRideText").removeClass("OverRideText");
    $("#tdlblOverRideText").addClass("OverRideTextHide");

CSS

td.OverRideText {
    font-style:italic;
    text-align:right !important;
    padding-right:1%;   
}
td.OverRideTextHide {
    font-style:italic;
    text-align:right;
    padding-right:10%;   
}

Since its a lazy loading I cannot use

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "text", "jsmethod();", true);

because this will call the js method on second time load and not for the first pageload.

all. I've never worked with destructors nor dispose, so this is new to me. I have a task of doing a class that has destructor and dispose methods, and that has a UInt64 Id property that is auto-incremental, and a static Dictionary<UInt64,MyClass> that must reference by Id all live instances of MyClass.

After searching how to use them properly, this is what I ended up doing:

public class MyClass : IDisposable
{
    private static Object Lock = new Object();
    private static Dictionary<UInt64, MyClass> LiveInstances = new Dictionary<UInt64, MyClass>();

    public UInt64 Id { get; private set; }

    public MyClass()
    {
        lock (Lock)
        {
            var newId = IncrementalId();
            if (newId == 0)
            {
                throw new ArgumentException("Reached MAX VAL");
            }
            Id = newId;
            LiveInstances.Add(Id, this);
        }
    }

    ~MyClass()
    {
       CleanUpNativeResources();
    }     

    public void Dispose()
    {
        lock (Lock)
        {
            CleanUpManagedResources();
            CleanUpNativeResources();
            GC.SuppressFinalize(this);
        }
    }

    protected virtual void CleanUpManagedResources()
    {
        LiveInstances.Remove(Id);

    }
    protected virtual void CleanUpNativeResources()
    {

    }

    private static UInt64 IncrementalId()
    {
        for (ulong i = 0; i <= Convert.ToUInt64(LiveInstances.Count) ; i++)
        {
            if (i != UInt64.MaxValue && !LiveInstances.ContainsKey(i + 1))
            {
                return i+1;
            }
        }
        return 0;
    }
}

Now, my question is How do I dispose objects? Whether I try to find examples of disposing objects, I find something like this:

 // Code to dispose the managed resources of the class
 Console.WriteLine("Object disposed");

Thanks in advance.

I have used weareoutman ClockPicker in my MVC project and it is perfectly working when I have only one clockPicker field in my View. When for example for Meeting table I need a start and an end time, the second clockPicker does not function(when I click there is no clockPicker).

Here's how I use it in my Create View:

    <div class="form-group">
        @Html.LabelFor(model => model.StringStartTime, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.StringStartTime, new { htmlAttributes = new { @class = "form-control clockPicker", id = "single-input", value = "", placeholder = "اکنون" } })
            @Html.ValidationMessageFor(model => model.StringStartTime, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.StringEndTime, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.StringEndTime, new { htmlAttributes = new { @class = "form-control clockPicker", id = "single-input", value = "", placeholder = "اکنون" } })
            @Html.ValidationMessageFor(model => model.StringEndTime, "", new { @class = "text-danger" })
        </div>
    </div>

So again the problem: the second clockPicker does not function(After clicking on the text box, the clockpicker does not pop up). What have I done wrong?

In my C# project, I have a file titled MyHelpers.cshtml under the App_Code folder, containing the following code:

    @helper MakeNote(string content) {
      <div class="note" 
           style="border: 1px solid black; width: 90%; padding: 5px; margin-left: 15px;">
        <p>
          <strong>Note</strong>&nbsp;&nbsp; @content
        </p>
      </div>
    }

I created a MyTest.cshtml directly in the root folder, with the following content:

<!DOCTYPE html>
  <head>
    <title>Test Helpers Page</title>
  </head>
  <body>
    <p>This is some opening paragraph text.</p>

    <!-- Insert the call to your note helper here. -->
    @MyHelpers.MakeNote("My test note content.")

    <p>This is some following text.</p>
  </body>
</html>

App_Code/MyHelpers.cshtml works when called from MyTest.cshtml.

I am using RazorEngine to generate HTML emails, and my actual template files are stored in a folder named EmailTemplates. When I insert the same line @MyHelpers.MakeNote("My test note content.") as I did with MyTest.cshtml in any CSHTML file in EmailTemplates, I get the following error:

The server encountered an error processing the request.
The exception message is 'Unable to compile template.
The name 'MyHelpers' does not exist in the current context.
Other compilation errors may have occurred.
Check the Errors property for more information.'

How do I get the CSHTML files in the EmailTemplates folder to use the MakeNote function in App_Code/MyHelpers.cshtml , just as how MyTest.cshtml uses it?

I am developing in Asp.NET Web Forms, and attempting to implement the use of TinyMCE rich text editor.

On my page I have a textbox control, that is set up to initialize with the TinyMCE editor. I also have a required field validator set to validate that the text box has input on a button click.

The problem that I am having is that on the first click, even when there is text in the textbox, the page is not validating saying that there is no text in the textbox. If i simply click the button again, without changing any text then the page validate and returns to the server.

in the jquery document ready

                tinymce.init({                  
                selector: ".mcetiny",
                theme: "modern",
                plugins: [
                 "advlist autolink lists link image charmap print preview hr anchor pagebreak",
                 "searchreplace wordcount visualblocks visualchars code fullscreen",
                 "insertdatetime media nonbreaking save table contextmenu directionality",
                 "emoticons template paste textcolor"
                ],
                toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
                toolbar2: "print preview media | forecolor backcolor emoticons",
                image_advtab: true,
                templates: [
                    { title: 'Test template 1', content: 'Test 1' },
                    { title: 'Test template 2', content: 'Test 2' }
                ]
            });

the textbox

                            <asp:TextBox ID="tbxTinymce" CssClass="mcetiny" TextMode="MultiLine"  runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator runat="server" ID="RFVtxtLogEntry" ControlToValidate="tbxTinymce" Text="*" 
                            ErrorMessage="Log Entry is required" Display="None" ValidationGroup="valInputForm">
                        </asp:RequiredFieldValidator>

button

                            <asp:Button ID="btnAdd" runat="server" Text="Save" OnClick="btnAdd_Click" ValidationGroup="valInputForm" />

In addition to this, when I load text into the text box during an edit feature, then change the text and submit an update function, it posts back without the validation error, because text was loaded into the box, it does not actually register the changes to the text...it updates the record with the original text.

Why is the tinymce textbox not automatically registering the text/changes until the second submit???

What would be the best way to display 50K employee records in an asp.net webpage. Please suggest possible ways available to fetch the records, storing the records and options for displaying them.

I have two web pages. I am using HTML Table to load data on it. I have used the labels to when load the data into the table and it is working fine. The table is nested inside the repeater. From the table, I have add Link button which i have renamed it to "Edit" ,When you click Edit link it will take you to another web page which is Form 2.

  1. Click Edit and opens form 2
  2. The data must be populated on the text boxes(I have place three text boxes for testing purposes)
  3. I will be able to edit from the text box and the update
  4. Click update button to update.(I have the code for update)
  5. Form2 controls(txtname,txtsurname and txtgrade)

Problem I cannot get it to load the selected rows on form2 text boxes. I am getting error and not sure of my code. see the code below

FORM1

Loading Method

    public void Load()
    {
        var _data = _dc.tblStudents.Where(c => c.StudentID <= 100);
        Repeater1.DataSource = _data;
        Repeater1.DataBind();
    }

ASPX

<table border="1" width="60%">
<tr style="background-color:#669acc;">

 <td><b>ID</b></td>
 <td><b>Fullname</b></td>
 <td><b>Surname</b></td>
 <td><b>Age</b></td>
 <td>&nbsp;</td>
 </tr>
 <asp:Repeater ID="Repeater1" runat="server">

 <ItemTemplate>
 <tr style="background-color:#f2f7fd;">

 <td >
     <asp:Label ID="lblIDnumber" runat="server" Text='<%# Eval("StudentID")%>'></asp:Label>
 </td>

 <td>
     <asp:Label ID="lblFullname" runat="server" Text='<%# Eval("Fullname")%>'></asp:Label></td>
 </td>

 <td>
     <asp:Label ID="lblSurname" runat="server" Text='<%# Eval("Surname")%>'></asp:Label></td>
 </td>

  <td>
     <asp:Label ID="lblGander" runat="server" Text='<%# Eval("Grade")%>'></asp:Label></td>
 </td>
      <td>
         <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Edit...</asp:LinkButton>
      </td>
 </tr>
 </ItemTemplate>
</asp:Repeater>
    </table>

Link Button (Am getting error under link button)

    protected void LinkButton1_Click(object sender, EventArgs e)
    { 
        var _L = _dc.tblStudents.Where(a => a.StudentID == int.Parse(Session["StudentID"].ToString())).ToList(); // ERROR : Exception has been thrown by the target of an invocation.

        foreach (tblStudent _List in _L)
        {
            txtname.Text = _List.Fullname;
            txtsurname.Text = _List.Surname;
            txtgrade.Text = _List.Grade;
        }

        Response.Redirect("FrmTable.aspx");

Form2

ASPX

          <table style="width:100%;">
                    <tr>
                        <td class="auto-style5"></td>
                        <td class="auto-style5"><b>Fullname :</b></td>
                        <td class="auto-style5">
                            <asp:TextBox ID="txtname" runat="server" Width="197px"></asp:TextBox>
                        </td>
                        <td class="auto-style5"></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><b>Surname :</b></td>
                        <td>
                            <asp:TextBox ID="txtsurname" runat="server" Width="197px"></asp:TextBox>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="auto-style4"></td>
                        <td class="auto-style4"><b>Gender :</b></td>
                        <td class="auto-style4">
                            &nbsp;</td>
                        <td class="auto-style4"></td>
                    </tr>
                    <tr>
                        <td class="auto-style2"></td>
                        <td class="auto-style3">Grade :</td>
                        <td class="auto-style2">
                            <asp:TextBox ID="txtgrade" runat="server" Width="71px"></asp:TextBox>
                        </td>
                        <td class="auto-style2"></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><b></b></td>
                        <td>
                            <asp:Button ID="btnSave" runat="server" Text="Save" Width="96px" OnClick="btnSave_Click" />
                        &nbsp;
                            <asp:Button ID="btnUpdate" runat="server" Text="Update" Width="87px" OnClick="btnUpdate_Click" />

Update Button

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (ViewState["StudentID"] != null)
        {
            List<tblStudent> _StudentList = _dc.tblStudents.Where(a => a.StudentID == int.Parse(ViewState["StudentID"].ToString())).ToList();

            if (_StudentList != null)
            {
                if (_StudentList.Count() > 0)
                {
                    foreach (tblStudent _StudentRow in _StudentList)
                    {
                        _StudentRow.Fullname = txtname.Text;
                        _StudentRow.Surname = txtsurname.Text;
                        _StudentRow.Grade = txtgrade.Text;
                    }
                    _dc.SubmitChanges();

                     lblResults.Text = "Confirmation: Student has been saved successfully!";
                }
                else
                {
                }
            }
        }
    }

I'm using below code to create a ClaimIdentity in OpenIdConnectServerProvider.AuthorizationProvider. But the identity.Name is not searlized. How to allow the OpenIdConnectServer serarlize the name? Thanks.

The previous question is here How to create a ClaimIdentity in asp.net 5

var user = await userManager.FindByNameAsync(context.UserName);
var factory = context.HttpContext.RequestServices.GetRequiredService<IUserClaimsPrincipalFactory<ApplicationUser>>();
var identity = await factory.CreateAsync(user);                
context.Validated(new ClaimsPrincipal(identity));       

I have a web application in asp.net and I want to prevent that two users login with the same username in the same time. I'm looking for a solution that let me to know a user with a special username is logged in so don't let to second user to login. I have tried Session and Application variables but each of them had a problem. when user close the browser or when the internet connection lost my application should log out that user so the second user can login. I don't know how should I handle this problem :(

I've the following problem. I perform an Ajax call from JS to a aspx page, passing as parameter a base64 encoded pdf. My calling function is the following:

function PDF_Generator(base64)
{

var ESBParams = 
{
    encodedString : base64
}

try
{
    $.ajax({
        method      : "POST",
        url         : pws_PDF_parsing_url,
        data        : ESBParams,
        dataType    : "html",
        async       : "false",
        error       :
        function (xhr, err, errth){
            alert('ERROR:' + errth);
        },
        success     :
        function (success){
            window.open(success);
        }
    });
}
catch(obj)
{
    alert(obj.messsage);
}
}

Now, I have the following aspx page which decode the base64 string, and I would come back the stream of decoded pdf to javascript function, in order to visualise it in a new page (or in an another way - I'll appreciate any advices).

using System;

public class PDF_Generator : System.Web.UI.Page
{
private string decodedPDF;
private string base64EncodedPDF;
Decoder decoder = new Decoder();

protected void Page_Load(object sender, EventsArgs e)
{
    try
    {
        this.base64EncodedPDF = Request.Params["encodedString"]; //get encoded string from js
        this.decodedPDF = decoder.decodeFromBase64toString(this.base64EncodedPDF); //decode string

        byte[] pdfByteStream = decoder.getBytesFromString(this.decodedPDF);

        Page.Response.ClearContent();
        Page.Response.ContentType = "application/pdf";
        Page.Response.AddHeader("Content-Disposition", "inline; filename=" + "summary.pdf");
        Page.Response.AddHeader("Content-Length", pdfByteStream.Length.toString());
        Page.Response.BinaryWrite((byte[])pdfByteStream);
        Page.Response.End();
    }
}
}

I have an issue in redirecting to the external URL Requirement I want to redirect to an external URL whenever the session is expired .... I have a separate class in which I override the definition of onActionExecuting Action Here is my Code ...

public class SessionExpireAttribute : ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
       // var redirectUrl = "http://www.google.com";
        var isAjaxRequest = filterContext.HttpContext.Request.IsAjaxRequest();

        if (isAjaxRequest)
        {
            filterContext.Result = new RedirectResult("http://www.google.com");
            return;
        }
        base.OnActionExecuting(filterContext);

    }
}

I Have try almost all the solution that I could find on Stack Over Flow but my problem is not still solved.

Is there is any issue related to pipeline execution of controller filters if so kindly guide me ... Note on console its shows this error

XMLHttpRequest cannot load http://www.google.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:49815' is therefore not allowed access. Thanks in advance.

I'm having a few issues with razor and yet again it's stressing me out.

I opened a project which is littered with Red Squiggles within the razor. This is very much a challenge as I'm a Webforms developer moving over to MVC.

I'm running visual studio 2015 enterprise.

At first I thought it might be a version issue but all seems good. WebConfig seems up to date. I'm at a loss, and in need of guidance. Any help greatly appreciated!

enter image description here

///EDITS

Views web.config.

  <add namespace="System.Web.Mvc" />
  <add namespace="System.Web.Mvc.Ajax" />
  <add namespace="System.Web.Mvc.Html" />
  <add namespace="System.Web.Routing" />
  <add namespace="System.Web.Optimization" />

It looks like I'm missing the razor namespace. I cannot actually add this in the references.

Just imagine that I have a model with 20 fields and I have 1000 records now but my database is growing up every day, then I want to list them in a razor page and show all of them but just 5 of fields needed.

I just want to know is it OK if I return the model with all fields to my view and choose the fields I need in my view or I should create a viewModel with that fields I just need ? I am worried about the performance.

I am trying to format currency decimals using superscript, e.g. $1.08 instead of $1.08. Currently, my model currency variable (assume 1.08 value) shows as $1.08 using a model template and MVC4 Razor / Javascript:

[Range(0, 10000)]
[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:C}")]
public decimal Price { get; set; }

@{
    @Html.Display(model => model.Price)
}

Instead, I tried to extract and format decimals using REGEX, but it still displays as $1.08 (P.S. currency localization not important at this time):

@{
    var numRaw = Model.Price;
    var numSty = numRaw.ToString.Replace("(?<=\\.)([^.]*$)", "<sup>$1</sup>");
    @Html.Raw(numSty);
}

Note the double backslash \\. escape. The search expression seems to work correctly.

Am I doing something wrong in the "<sup>$1</sup>" replace string?

We are still using asp.net mvc WebForms (legacy code) with a lot of our own frameworks.
one of our features is gathering the static content on run time and creating the min and optimize versions. (we found out it was faster).

Yet Razor rendering pipeline is different then WebForms, so the content is rendered out of order.

For example we have a view to render lets call it Home, Home has several calls to X.Css("css_x"); we gather them into a 'list' Home has partial view to render which inside also has X.Css invocation.

After Home is rendered into the output buffer stack the _Layout is rendered again with X.Css being called. assume that now we need to render all of the css files but the order is wrong.

How is it possible to synchronize view and layout with the order i need (first layout then views and partials)

Any one got an idea.

(if i am not understood please let me know and i'll try to elaborate more)

I have the following razor markup

<a href="@Model.WebsiteAddress" target="_blank" rel="nofollow"><span>@Model.WebsiteAddress</span></a>

Where WebsiteAddress is a field which the user entered. Many times the users just write their website address without the http:// part. For example: WebsiteAddress = www.google.com

Now when the user clicks on the link if it does not contain http:// then a new tab is opened with MY website address as prefix to the actual WebsiteAddress. For example: http://www.mywebsite.com/www.google.com

What can I do so that the address will always linked to the right website?

I'm just getting my feet wet with ASP.NET MVC 5 and Kendo. Using the existing MS tutorials, I've created an ASP.NET project that does roughly what I want (some data input from various users). Now I'm trying to add Kendo UI to the project, but I'm not sure how to convert the existing Razor cshtml to use Kendo correctly.

For example, I have:

@Html.EditorFor(model => model.someDate, new { htmlAttributes = new { @class = "form-control" }})

I tried changing it to:

@Html.Kendo().DatePickerFor( model => model.someDate).Name( "someDate" ).HtmlAttributes( new { style = "width:100%" } )

This works, in that I see the Kendo UI date picker. But if I use it to choose a date and save the data, I get this exception:

Exception Details: System.Data.SqlClient.SqlException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

I'd thought I could just drop in the Kendo controls, but apparently not. Is it possible to get this to work just like the original Html.EditorFor code? If so, how?