In .NET 2.0 accessing the values stored in web.config through System.Configuration.ConfigurationSettings.AppSettings doesn’t seem to work anymore

In .NET 2.0 System.Configuration.ConfigurationSettings.AppSettings has been changed to System.Configuration.ConfigurationManager.AppSettings. Also youneed to add a reference to System.Configuration.dll.Here’s an example of accessing the SomeString value from the web.config file, in .NET 2.0: System.Configuration.ConfigurationManager.AppSettings[“SomeString”];

How do I generate a random number within a range?

Using .NET you can easily generate a random number withing a range, by using the Random class. In the following example a random number between 1 and 69 will be generated: System.Random RandNum = new System.Random();int MyRandomNumber = RandNum.Next(69); To generate a random number between 1986 and 2005 you would use: System.Random RandNum = new System.Random();int MyRandomNumber = RandNum.Next(1986, […]

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 […]