In ASP.NET when you add a new item using a line such as the one below, and there are items already in the DropDownList, you will notice that this one is added at the bottom of the list. ddlMyList.Items.Add(“The Swan”);Sometimes you will be able to move this line in your code relative to the other […]
A disabled TextBox or similar control does not maintain its value through PostBack
It is normal behaviour for an ASP.NET TextBox and other controls similar to it to lose their value through PostBack when they have the Disabled attribute set to True. To work around this behaviour, you can either use a Hidden type of field if you don’t want the user to see the value of the field in the page, or […]
Can I use my existing DLLs with ASP.NET?
If you have existing DLLs or COM objects developed and compiled in different languages such as Visual Basic, the good news is that you can use them in your ASP.NET web application just like any other DLLs. In Visual Studio, all you need to do is add a reference to the DLL via the Solution […]
How to retrieve the installed ASP.NET version
It happens many times that you don’t have access to an ASP.NET server, except for FTP, and you’re interested in finding out the version of .NET Framework or ASP.NET that runs on that server.To find out what version of ASP.NET you have installed and running on a server, using ASP.NET itself, you can use the System.Environment.Version – […]
How do I get the list of all session variables?
In ASP .NET, how do I set the script timeout?
You can use the following property (value in seconds): Page.Server.ScriptTimeout = 60; Also using this property you can retrieve the current time-out.
How to redirect to a different page using Response.Redirect in ASP.NET
You only need to use a simple method for redirecting to an URL in ASP.NET: Response.Redirect(). In the example below we are redirecting to http://www.geekpedia.com: Response.Redirect(“http://www.geekpedia.com“); You don’t have to type an absolute URL if the file is located on the same server. In that case you can use relative paths: Response.Redirect(“NewFile.aspx”);
The name ‘Request’ does not exist in the current context
This error normally occurs when you are trying to access a property such as Request.Cookies and you’re not doing that from a webform, usercontrol or a class that inherits from System.Web.UI. Nothing to worry about, since you can still access these properties, but using a different path.For example to access a cookie with the name MyCookie you would normally […]
Cannot implicitly convert type ‘string’ to ‘System.Drawing.Color’
Certain ASP.NET controls such as the label can be assigned to it colors (background colors, foreground colors, etc.) at runtime from the code-behind files. Even though the label renders into an HTML entity, you cannot directly assign a color that is in the Hex format (such as #FF00EE); if you try you will receive the […]
The file web.sitemap required by XmlSiteMapProvider does not exist.
The most common case when the “The file web.sitemap required by XmlSiteMapProvider does not exist” error is received is when a SiteMap control was added to a WebForm, however you don’t have a mandatory Web.sitemap file in the root of your web application.To fix this error, make sure you have this file in the root directory, and that it is a […]