Parser Error: Server Error in ‘/’ Application

Right-click your Global.asax file and click View Markup. You will see the attribute Inherits=”nadeem.MvcApplication”. This means that your Global.asax file is trying to inherit from the type nadeem.MvcApplication. Now double click your Global.asax file and see what the class name specified in your Global.asax.cs file is. It should look something like this: namespace nadeem { … Read more

How to access a JavaScript variable from code behind in asp.net

You will need to store the count variable on a server-side control in order to do this. Example: <script type=”text/javascript”> var count = 0; jQuery(‘td’).click(function () { if ($(this).hasClass(‘process’)) { count = count + 100; alert(count); // Store the value in the control $(‘#<%= example.ClientID %>’).val(count); } }); </script> <asp:HiddenField ID=”example” runat=”server” /> Then, in … Read more

how to access master page control from content page

In the MasterPage.cs file add the property of Label like this: public string ErrorMessage { get { return lblMessage.Text; } set { lblMessage.Text = value; } } On your aspx page, just below the Page Directive add this: <%@ Page Title=”” Language=”C#” MasterPageFile=”Master Path Name”….. %> <%@ MasterType VirtualPath=”Master Path Name” %> // Add this … Read more

Calling javascript from code behind

Assuming that the pre-conditions are true. You need to pass an additional parameter to the RegisterClientStartupScript method call to indicate that scriptTags need to be added. Page.ClientScript.RegisterStartupScript(this.GetType(), “openCredentials”, string.Format(“radopen(‘Services.aspx?clientId={0}, Window_Services’)”, openCredentialsWindow_ClientId.ToString()),true);

Create DataTemplate in codebehind

Although Archedius’s method works, officially it is deprecated and instead recommended way to programmatically create a template is to load XAML from a string or a memory stream using the Load method of the XamlReader class like this… public DataTemplate Create(Type type) { StringReader stringReader = new StringReader( @”<DataTemplate xmlns=””http://schemas.microsoft.com/winfx/2006/xaml/presentation””> <” + type.Name + @” … Read more