ASP.NET renders CheckBox control inside span if CssClass is set

I added an ASP.NET CheckBox control to a form I was creating and was surprised to see the following unexpected html rendered when CssClass property was set for the control: ASP.NET code: Rendered HTML: I tried adding the class attribute to the control’s Attributes collection in code-behind without success. Finally, after reading StackOverflow and MSDN, …

Continue reading

How To Validate A CheckBox ASP.NET Control

If you attempt to use a RequiredFieldValidator with a CheckBox control, you will get a runtime error that says something like “Control {your checkbox control id} referenced by the ControlToValidate property of {id of your validator control} cannot be validated”. If you want to require an ASP.NET CheckBox control be checked when a form is …

Continue reading

How To Use A RequiredFieldValidator With A DropDownList

I love the ASP.NET validation controls. There are times however when you need to know the ins-and-outs to use them successfully. For example, what do you do when you want to require an option to be selected from a DropDownList on the client side? If you simply add a RequiredFieldValidator, set the right ValidationGroup and …

Continue reading

How To Get Connection Strings From web.config

In c# it’s quite easy to get a connection string from web.config at run-time without having to manually parse the xml with the aid of the System.Configuration library. First you need a reference to the System.Configuration library – you add the reference via the “Add Reference” feature of your project and you then include the …

Continue reading

Visual Studio 2010 WebServer Slow Loading

I do a lot of contracted work in ASP.NET (C#). In fact, you could say a major part of my working day is spent on debugging or developing features for a client in ASP.NET 4 (C#). I was recently faced with a really strange problem. I was experiencing extremely slow loading times when attempting to …

Continue reading