Showing posts with label ASP. Show all posts
Showing posts with label ASP. Show all posts

2010-10-07

OnRowCommand does not fire in ASP.Net gridview

All of a sudden all the command buttons stopped working in a gridview in my project. The OnRowCommand event did not fire.
Turns out last week I set the EnableViewState property of the grid to false. Never disable the ViewState of a gridview!

Short:
If all of a sudden the OnRowCommand stops firing in your ASP.Net GridView make sure that the EnableViewState property of the grid is set to true.

2009-04-09

Double page load/postback

I have spent 3 days once to figure out why an ASPX page does a double page postback when it shouldn't. The first request was OK, then immediately a second postback followed without the post data. This strange behavior occurred only in Firefox.

I discovered what the issue was:
I had an image control on the page with it's src attribute empty. Firefox uses the current page's URL as the src of the image. Hence the second postback.

This guy explains it better than me:

2008-09-17

How to add spaces to ASP ListBox control

Problem:

When trying to indent some elements of the ListBox or DropDownList ASP controls with multiple spaces the browser only renders one space. Trying to add   instead of a space character renders the letters "&", "n", "b", "s", "p".

Solution:

Add Server.HtmlDecode(" ") instead of a simple space and everything should look fine.

private void FillList()
{
    listBox.Items.Add("Root");
    listBox.Items.Add(Server.HtmlDecode(" ") + "First level");
    listBox.Items.Add(Server.HtmlDecode("  ") + "Second level");
    listBox.Items.Add(Server.HtmlDecode("  ") + "Also second level");           
}

2008-05-13

ASP.NET Development Server problems under Vista (maybe Windows 7)

Problem
When hitting Ctrl-F5 in Visual Studio 2005/2008 to run a web application in Vista, the Development Server gets started, Internet Explorer opened but nothing happens, although the web application is set to run with Development Server, ASP, ISS and everything required is installed.

Solution
Go to c:\Windows\System32\drivers\etc\ and open the file named hosts with a text editor
Search for the line containing "::1" mapped to "localhost"
Change "::1" to ":::1" by adding an extra ":"
Save the file and everything should be running fine

2008-04-13

Failed to access IIS metabase error while trying to access ASP page on localhost

When trying to open a website on my localhost I received the following error message:

"Failed to access IIS metabase.
Description: [...]
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 http://support.microsoft.com/?kbid=267904."

After some digging I discovered that the cause of the problem is that I installed Visual Studio 2008 before installing IIS.
The problem can be fixed by running aspnet_regiis.exe /i (I think it's called aspnet_iisreg.exe in older versions of VS) from the Visual Studio 2008 Command Prompt or from the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727> folder.

2008-02-17

Asp.net: Directives

A very good description of ASP.Net directives:

2008-01-22