Thanks to the AutoPostBack attribute, you can easily submit the form when the user selects an item from a DropDownList. All you need to do is set the AutoPostBack attribute to true inside the DropDownList tag, as seen in the following example:
A page can have only one server-side Form tag
In ASP.NET 1.1, only one server-side form tag is allowed on a page. This error occurs if you have two or more server-side form tags on your page.A server-side form tag is the tag which has a runat=”server” attribute. If this attribute is missing, then it’s a typical HTML form tag. The conclusion is that you are […]
ASP.NET DropDownList of countries
Below you can find a complete list of countries as ListItems inside an ASP.NET DropDownList:
What are the special directories in ASP.NET 2.0
When creating a new ASP.NET 2.0 website in Visual Studio 2005 you may notice the App_Data and/or the App_Browsers directories. App_Data is a directory reserved for databases and database related files, such as .mdb (Microsoft Access Database), .mdf (Microsoft SQL Express) or XML files. The main advantage of using this folder over any other folder is the preconfigured access permissions, […]
Can ASP.NET 1.1 applications work along with ASP.NET 2.0 applications?
As long as you have ASP.NET 1.1 and ASP.NET 2.0 installed on your server, both types of web applications will work fine. When you install ASP.NET 2.0, ASP.NET 1.1 doesn’t get uninstalled so you don’t have to worry.However, after you install ASP.NET 2.0 make sure you put your ASP.NET 2.0 web applications on a different […]
How can I set the date of a Calendar control to the current date?
Most of the time when using a calendar in your Windows or web application, you’ll want to set its initial date to the current date. This can be easily done using the SelectedDate property: Calendar1.SelectedDate = System.DateTime.Now;
How can I set the ASP.NET validators to be visible by default?
To make the validators on a page visible by default you can call the page’s Validate() method when it is loading, as in: private void Page_Load(object sender, System.EventArgs e){ if (!IsPostBack) { Page.Validate(); }} Or if you want to make visible only one validator, use: private void Page_Load(object sender, System.EventArgs e){ if (!IsPostBack) { // Where reqEmail is […]
ASP.NET DropDownList of US states
Below there is a list of states inside United States, each being a ListItem inside an ASP.NET DropDownList:
Adding an item in a DropDownList at a certain position
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 […]