Some FAQ from ASP.NET web development

Hello! How are you doing? Today, I wanna share with you some of the notes that I have made while I was working in ASP.NET project. I started playing with .NET since September, 2004. I used to face a lot of problems and have to find the solutions for those problems. I wanna share all of those problems and solutions that I’ve faced. But unfortunately, I didn’t remember all of these since I didn’t make any note in my outlook. Anyway, I’ll share with you what I have in my mail. Hopefully, you may find it useful.

1. How to invoke/fire JS function after validating of ASP.NET validator?

Use “Page.RegisterStartupScript(,)” function as below.

        string strScript   = "";
        strScript += "function foo(){";
        strScript += " alert('This is foo!');";
        strScript += "}";
        strScript += "";Page.RegisterStartupScript("bear",strScript);

2. Is it possible to access the Javascript variable from Server-side?

Follow the steps below if you wanna share something between the client-side script and server-side script.

  1. Add Server-side hidden field in your page.
  2. Set the value of Javascript variable to this hidden field by using document.getElementById() function.
  3. then, get the value of that hidden field.

Note: I used this technique in this sample. You may check it out.

3. Why all data from web controls within the disabled panel has been lost during the postback?

It’s pretty strange. In window-based application, we only need to disable the panel if we want to disable all controls inside this panel. But we can’t do like that in web development. ASP.NET doesn’t keep the viewstate of the controls if the panel is disabled so that all data in those controls within disabled panel will be lost during the PoskBack.
The solution for this problem is that enable or disable each and every controls inside the disabled panel. Enable explicitly.

Scott Mitchell wrote very good article about this problem and solution in this blog.. You may check his article “Panel Weirdness” here.

4. How to set the width of textbox in percentage? [esp: for Firefox users.]

This is the problem that I faced when I was developing cross-browser web application. What happen was that I wanna set the width of a textbox to 100%. So, I set 100% to the width property of textbox in Design Mode. But the style that i set to textbox doesn’t load in Firefox. It automatically change from 100% to 100. I have no idea why it was happening like that. However, I could come up with the solution for that problem. The solution is that write the style you want as a CSS class in CSS file and set it to the textbox.

5. I used to get this error “Access is Denied: Microsoft.Web.UI.Webcontrols”” very often while running project from VS.NET IDE.Why?

Solution #1 ~

  • Stop Indexing Service.


Details ~

If you do not use Index Server on the server, you can disable it. To do so, follow these steps:
1. Click Start, and then click Services.
2. Locate Indexing Service from the list of services, and then click Indexing Service Properties from the subform.
3. On the General tab of the Indexing Service Properties dialog box, in the Startup type drop-down item list, click Disabled.
4. Click OK.

If you use Index Server, you can exclude the Temporary ASP.NET Files directory from the folders that the Index Server scans. To do so, follow these steps:
1. Click Start, point to All Programs, point to Administrative Tools, and then click Computer Management.
2. Expand the Services and Applications node, expand the Indexing Service node, and then expand the System node.
3. Right-click the Directories folder, point to New, and then click Directory from the subform to open the Add Directory dialog box.
4. Click Browse, and then locate the Temporary ASP.NET Files directory. You typically find the Temporary ASP.NET files in the following path: c:\\Microsoft.NET\Framework\\Temporary ASP.NET Files
Note is the version of .NET Framework installed on your computer.
5. Click No under the Include in Index? option buttons.
6. Click OK to close.
7. Close the Computer Management dialog box.
8. Restart the Indexing Services service.

Solution #2 ~

In the web.config file if the tag identity impersonate=”true” is added, remove it and see. [Don’t ask me why :)] [Ref: ]

5. I’m using EnterpriseLibrary latest version in my ASP.NET project. I used to get this error message “This schema for this assembly has not been registered with WMI.” while building my web project. Why?

Solution ~

  1. Open up the EnterpriseLibrary.sln and modify the Configuration Properties\Build\Conditional Constants of the EnterpriseLibrary.Common project.
  2. Remove the USEWMI;USEEVENTLOG;USEPERFORMANCECOUNTER constants. By removing these constants, all of the internal Enterprise Library instrumentation will be disabled.
  3. Recompile.

Ref :

6. Protecting an ASP.NET page against malicious input with ValidateRequest (A potentially dangerous Request.Form value was detected)

When your project is in testing state, you should try to test your application by entering script tag (eg: <script lanague=”javascript”>) or HTML tag (eg: <html><strong>) or #@ or @# characters. And see what happen.. You may probably get the error.. If you don’t wanna get this error then you have to set the page directive validateRequest to false. Note that your page might has the security problem.


That’s all for now. If you have any useful tip for ASP.NET development, you can mail me at mchlsync AT with the subject “[Michael Sync’s blog – ASP.NET Tips]”. Thanks a lot.

Related Articles ~

  1. [Tips/Tricks] ASP.NET with SQL Reporting Services
  2. Tips/Tricks – How to control MaxLength of Multiline TextBox in ASP.NET 1.1?

Leave a Reply