How to refresh a ASPxGridView summary value on the client side

The ASPxGridView is a server side control, so it renders on the server side.

If you know how the summary value should be changed using the client side code, you need to do the following:

1) add the ASPxLabel to the column's FooterTemplate container and set its ClientInstanceName to a some value, for example, lblFooter;
2) use the lblFooter.SetText('some text') to change the displayed summary value.

Here is some sample code:


<dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="1">
<EditFormSettings Visible="False" />
<dx:ASPxLabel ID="ASPxLabel1" ClientInstanceName ="lblFooter" runat="server"
Text="<%# GetSummaryValue(Container)%>">


protected string GetSummaryValue(GridViewFooterCellTemplateContainer container) {
ASPxGridView gridView = container.Grid;
GridViewDataColumn column = container.Column as GridViewDataColumn;
if(column == null)
return string.Empty;
for(int i = 0; i < gridView.TotalSummary.Count; i ++)
if(gridView.TotalSummary[i].FieldName == column.FieldName) {
return gridView.GetTotalSummaryValue(gridView.TotalSummary[i]).ToString();
return string.Empty;

Creating Arrary in JavaScript

Create an Array

An array can be defined in three ways.

The following code creates an Array object called myCars:

Listing 1:

var myCars=new Array(); // regular array (add an optional integer
myCars[0]="Saab";       // argument to control array's size)

Listing 2:

var myCars=new Array("Saab","Volvo","BMW"); // condensed array

Listing 3:

var myCars=["Saab","Volvo","BMW"]; // literal array

Note: If you specify numbers or true/false values inside the array then the variable type will be Number or Boolean, instead of String.

Access an Array

You can refer to a particular element in an array by referring to the name of the array and the index number. The index number starts at 0.

The following code line:


will result in the following output:


Modify Values in an Array

To modify a value in an existing array, just add a new value to the array with a specified index number:


Now, the following code line:


will result in the following output:


How User Controls Are Processed

The HTML portion of ASP.NET Web pages can contain a mix of Web controls, user controls, and HTML syntax. When an ASP.NET Web page is visited for the first time, or for the first time after a change has been made to the HTML portion of the Web page, a class is automatically created from the HTML portion. This class, which is derived from the Web page's code-behind class, constructs the Web page's control hierarchy based on the declarative syntax in the HTML portion.

For example, imagine that a Web page had the following markup in its HTML portion:

<form runat="server">

Name: <asp:TextBox runat="server" id="name"></asp:TextBox>
<br />
<asp:Button runat="server" Text="Submit"></asp:Button>



This would generate the following control hierarchy:


Figure 2. Controls hierarchy on page

Notice that the HTML markup is converted into LiteralControl instances, the Web Form into an HtmlForm object, and the TextBox and Button Web controls into their respective classes.

Once this control hierarchy is created, the ASP.NET Web page can be rendered by recursively invoking the RenderControl(HtmlTextWriter) method of each of the controls in the hierarchy. When a control's RenderControl(HtmlTextWriter) method is invoked, the control generates its HTML markup and appends it to the HtmlTextWriter object. Realize that each time an ASP.NET Web page is requested, the page's corresponding class is invoked causing the control hierarchy to be created and rendered.

User controls work in a similar fashion to ASP.NET Web pages. When a user control is visited for the first time, or for the first time after the HTML portion has been changed, the user control is compiled into a class that is derived from the user control's code-behind class. Like the ASP.NET Web page's autogenerated class, the user control's autogenerated class constructs a control hierarchy based on the HTML portion of the user control. In essence, a user control has its own control hierarchy.

Imagine, then, that we had a user control with the following HTML markup:

<asp:Label runat="server" id="lblCategoryName"></asp:Label>

<br />

<asp:Label runat="server" id="Description"></asp:Label>

The user control's control hierarchy, then, would look like the following:




Figure 3. Control Hierarchy for user control

Recall that an ASP.NET Web page's HTML portion can contain not only Web controls and HTML syntax, but user controls as well. user controls are entered into the control hierarchy as an instance of the user control's auto generated class. So, imagine we augmented our previous ASP.NET Web page example so that after the Button Web control was an instance of the user control whose declarative syntax we just discussed. This would cause the Web page's control hierarchy to look like the following:

Figure 4. Updated control hierarchy for page

After the user control class is added to the control hierarchy, the class's InitializeAsUserControl(Page) method is invoked. The InitializeAsUserControl(Page) method is defined in the System.Web.UI.UserControl class, which the autogenerated user control class is derived from indirectly. (Recall that the autogenerated user control class is derived from the user control's code-behind class; this code-behind class is derived from System.Web.UI.UserControl, similar to how an ASP.NET Web page's code-behind class is derived from System.Web.UI.Page.) The InitializeAsUserControl(Page) method generates the user control's class hierarchy and assigns the user control's Page property to the passed in Page instance, thereby allowing the user control to programmatically reference the Page to which it belongs. After InitializeAsUserControl(Page) runs, the Web page's control hierarchy looks like:


Figure 5. Updated page hierarchy after initializing the user control

Notice that once the user control is affixed to the control hierarchy and builds up its own control hierarchy, the page's control hierarchy appears just as it would if a user control hadn't been used, but instead had its HTML portion entered directly into the page's HTML portion. With this complete hierarchy, the Web page can be rendered by recursively calling the RenderControl(HtmlTextWriter) method of each control in the hierarchy.

Now that we've seen how a user control is handled underneath the covers, let's take a look at some of the more advanced concepts of user controls, starting with how to respond to events raised by Web controls in a user control.


Failed to access IIS metabase.

I have windows XP Professional installed on my machine and I got this error after
configuration of my virtual directory on IIS.

Server Error in '/myweb' Application.

Failed to access IIS metabase.

Description: An unhandled exception occurred during the execution of the current web request. Please review
the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.
The process account used to run ASP.NET must have read access to the IIS metabase
(e.g. IIS://servername/W3SVC). For information on modifying metabase permissions,
please see

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the exception
can be identified using the exception stack trace below.

Stack Trace:

[HostingEnvironmentException: Failed to access IIS metabase.]   
System.Web.Configuration.MetabaseServerConfig.MapPathCaching(String siteID, VirtualPath path) +1076   
System.Web.Configuration.MetabaseServerConfig.System.Web.Configuration.IConfigMapPath2.MapPath(String siteID, VirtualPath vpath) +9  
System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +301   System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath, Boolean permitNull) +51   
System.Web.CachedPathData.GetPhysicalPath(VirtualPath virtualPath) +39 
System.Web.CachedPathData.GetConfigPathData(String configPath) +704 
System.Web.CachedPathData.GetConfigPathData(String configPath) +583
System.Web.CachedPathData.GetApplicationPathData() +38  
System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) 8778063
System.Web.Configuration.RuntimeConfig.GetConfig(VirtualPath path) +46   
System.Web.Configuration.RuntimeConfig.GetLKGRuntimeConfig(VirtualPath path) +96

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Solution :-

This Error Caused Because You Not Have Register ASP.Net with IIS.
Please Follow Following Step to Regiser ASP.Net With IIS.

-> Go to Start - >  Run -> Cmd.

-> GO to Your System Drive Mostly C Drive.

-> Type C:\WINDOWS\Microsoft.NET\Framework\<your framework version directory>\aspnet_regiis -i

Just wait And Message comes Successfully Register.

Or you go to your visual studio command prompt in visual studio tools and run the same command

aspnet_regiis –i


A potentially dangerous Request.Form value was detected from the client

Server Error in '/' Application.


A potentially dangerous Request.Form value was detected from the client (txtCode="<br/>").

Description: Request Validation has detected a potentially dangerous client input value, and processing of
the request has been aborted. This value may indicate an attempt to compromise the security of your application,
such as a cross-site scripting attack. To allow pages to override application request validation settings, set the
requestValidationMode attribute in the httpRuntime configuration section to requestValidationMode="2.0".

Example: <httpRuntime requestValidationMode="2.0" />. After setting this value, you can then disable request
validation by setting validateRequest="false" in the Page directive or in the <pages> configuration section.
However, it is strongly recommended that your application explicitly check all inputs in this case. For more
information, see

Exception Details:System.Web.HttpRequestValidationException: A potentially dangerous Request.Form
value was detected from the client (txtCode="<br/>").
You have to do little modification to you application to get this fixed.

  1. Add <httpRuntime requestValidationMode="2.0" /> in your application web.config
       under <system.web>.
        <httpRuntime  requestValidationMode="2.0"/>
  2. Add RequestValidation="false" on your page or in web.config <pages>
    <%@ Page Language="C#" AutoEventWireup="true" ValidateRequest = "false"
    to work this for whole application do in web.config as:
        <httpRuntime  requestValidationMode="2.0"/>
        <pages validateRequest ="false"></pages>

IN clause With Linq To Sql

There is no direct equivalent in LINQ. Instead you can use contains () or any other trick to implement them. Here's an example that uses Conains ().:

String [] s = new String [5];
s [0] = "34";
s [1] = "12";
s [2] = "55";
s [3] = "4";
s [4] = "61";
var = RESULT1 from the day context.TableName
                        where s.Contains (d.fieldname)
                        select d;


int[] productList = new int[] { 1, 2, 3, 4 };   

var myProducts = from p in db.Products

                 where productList.Contains(p.ProductID)

                select p;

Start with the Order (pretend my order is ID=44):

AdventureWorks.DB db=new DB();

var itemQuery = from orders in db.SalesOrder

              where orders.SalesOrderID == 44

              select orders.ProductID;

Next we need to get the products, but only those that are in the cart. We do this by using our first query, inside the second:

var myProducts = from p in db.Products

                where itemQuery.Contains(p.ProductID)

                select p;

Securing ASP.Net pages - ASP.NET - Forms Authentication

ASP.Net has a built-in feature called forms authentication which allows developers to easily get certain areas of a website. In this post I will create a simple authentication example using C # and ASP.Net 4.0 (still in beta after the posting date).
The security settings with ASP.Net is configured from the web.config file. This is a standard ASCII file, an XML format, which is at the root of the web application. This is a sample web.config file:

<authentication mode="Forms">
<forms name ="TestAuthCookie" loginUrl="login.aspx" timeout="30">
<credentials passwordFormat="Clear">
<compilation targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5"clientIDMode="AutoID"/>


The first line is the standard for a web.config file and not related to security.
The following section specifies that you are configuring security for this web application. First, set the authentication mode to use a cookie in this specific example. You can specify a unique name for your cookie. This section also specifies the page or URL that contains the authentication code (login.aspx in this case) and the duration of the authentication cookie should be stored.
The next two lines specify the user names and passwords are valid for this web application. As far as I know there is no limit on the number of user accounts can be placed in the web.config, but if there were a large number - or if they change frequently - it might be best to put this information in an external file as a database or an XML file instead (I'll show this in a future article).
Now that we've identified some accounts valid login is necessary to specify in reality we want to password protect. For this example I decided to password protect the entire site from the root, so the optional attribute is not used. We have established the authority to deny all unauthenticated users (deny users ="?").
That's all it takes to file config.web. If someone tries to access the page and the user is not authenticated and will be redirected to login.aspx page.
This is only half the process required however. Now we have to create the login.aspx page to actually authenticate the user for our application.
Here is the complete source code for the login.aspx page shows:

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "login.aspx.cs"%>
DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "">
<html xmlns="">
<head runat="server">
    <title> </title>
  <form  id="Form1" runat="server">
    <asp:TextBox    ID="txtUsername" <asp:TextBox runat="server"> 
        <br />
   <asp:TextBox    ID="txtPassword" <asp:TextBox runat="server">
        <br />
       <asp:Button Text="Login" onclick="Button1_Click" ID="Button1"  runat="server" />
        <br />
        <br />
       <asp:Label runat="server" ID="lblStatus" Text="Please  login"> </asp:Label>
using System;
using System.Web.UI.WebControls;
using System.Web.Security;
public partial class Default3: System.Web.UI.Page
    protected void Button1_Click (object sender, EventArgs e)
        if (FormsAuthentication.Authenticate (txtUsername.Text, txtPassword.Text))
            lblStatus.Text = ("Welcome" + txtUsername.Text);
            FormsAuthentication.RedirectFromLoginPage (txtUsername.Text, true);
            lblStatus.Text = "Invalid login";

Dynamically add controls to footer row using RowTemplate

Create a Class that inherits ITemplate and add controls the container ; you want to add.
Assign the object of that class to ASPxGridView's Templates.FooterRow property as:

ASPxGridView1.Templates.FooterRow = new CustomFooterRowTemplate();
And the code snippet of the template class is below:
public class CustomFooterRowTemplate: ITemplate
     void ITemplate.InstantiateIn(Control container)
         Button button = new Button();
         button.Text = "Test"; 

have an idea from this and you can add more controls and even you can use their event handler in the custom template except using on the RowCommand event.