Change textbox’s css class when ASP.NET Validation fails

Here is quick and dirty thing (but it works!) <form id=”form1″ runat=”server”> <asp:TextBox ID=”txtOne” runat=”server” /> <asp:RequiredFieldValidator ID=”rfv” runat=”server” ControlToValidate=”txtOne” Text=”SomeText 1″ /> <asp:TextBox ID=”txtTwo” runat=”server” /> <asp:RequiredFieldValidator ID=”rfv2″ runat=”server” ControlToValidate=”txtTwo” Text=”SomeText 2″ /> <asp:Button ID=”btnOne” runat=”server” OnClientClick=”return BtnClick();” Text=”Click” CausesValidation=”true” /> </form> <script type=”text/javascript”> function BtnClick() { //var v1 = “#<%= rfv.ClientID %>”; //var … Read more

How can I use HTML5 email input type with server-side .NET

There is an update for .NET framework 4 which allows you to specify the type attribute http://support.microsoft.com/kb/2468871. See feature 3 way down the page Feature 3 New syntax lets you define a TextBox control that is HTML5 compatible. For example, the following code defines a TextBox control that is HTML5 compatible: <asp:TextBox runat=”server” type=”some-HTML5-type” />

Get All Web Controls of a Specific Type on a Page

Check my previous SO answer. Basically, the idea is to wrap the recursion of iterating through the controls collection using : private void GetControlList<T>(ControlCollection controlCollection, List<T> resultCollection) where T : Control { foreach (Control control in controlCollection) { //if (control.GetType() == typeof(T)) if (control is T) // This is cleaner resultCollection.Add((T)control); if (control.HasControls()) GetControlList(control.Controls, resultCollection); … Read more