Let’s start simple by creating form controls: <table> <tr><td>Usernname</td><td><asp:TextBox ID=”user” runat=”server”></asp:TextBox></td></tr> <tr><td>Password</td><td><asp:TextBox ID=”password” runat=”server” TextMode=”Password”></asp:TextBox></td></tr> <tr><td></td><td><asp:Button ID=”Button1″ OnClick=”submit” Text=”Login” runat=”server” causesValidation=”true” /></td></tr> </table> Now add some form validation: <table> <tr><td>Usernname</td><td><asp:TextBox ID=”user” runat=”server”></asp:TextBox> <asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ControlToValidate=”user” ValidationGroup=”UserCheck” ErrorMessage=” <font color=’red’> « Username is required!</font> “> </asp:RequiredFieldValidator> </td></tr> <tr><td>Password</td><td><asp:TextBox ID=”password” runat=”server” TextMode=”Password”></asp:TextBox> <asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ControlToValidate=”password” […]
Archive for May, 2011
GridView drop-down list record update:
Found this code on msdn library and use it all the time. Code is pretty straight forward and easy to implement and customizable. Have fun using it. <asp:TemplateField SortExpression=”CategoryName” HeaderText=”CategoryName”> <EditItemTemplate> <asp:DropDownList ID=”DropDownList1″ Runat=”server” DataSourceID=”categoryDataSource” DataTextField=”CategoryName” DataValueField=”CategoryID” SelectedValue='<%# Bind(“CategoryID”) %>’> </asp:DropDownList> </EditItemTemplate> <ItemTemplate> <asp:Label Runat=”server” Text='<%# Bind(“CategoryName”) %>’ ID=”Label1″></asp:Label> </ItemTemplate> </asp:TemplateField> For more related code […]
Classic ASP – Date and time formating
Code <script type=”text/vbscript”> document.write(DateAdd(“yyyy”,1,”31-Jan-10″) & “”) document.write(DateAdd(“q”,1,”31-Jan-10″) & “”) document.write(DateAdd(“m”,1,”31-Jan-10″) & “”) document.write(DateAdd(“y”,1,”31-Jan-10″) & “”) document.write(DateAdd(“d”,1,”31-Jan-10″) & “”) document.write(DateAdd(“w”,1,”31-Jan-10″) & “”) document.write(DateAdd(“ww”,1,”31-Jan-10″) & “”) document.write(DateAdd(“h”,1,”31-Jan-10 08:50:00″) & “”) document.write(DateAdd(“n”,1,”31-Jan-10 08:50:00″) & “”) document.write(DateAdd(“s”,1,”31-Jan-10 08:50:00″) & “”) </script> Output 1/31/2011 4/30/2010 2/28/2010 2/1/2010 2/1/2010 2/1/2010 2/7/2010 1/31/2010 9:50:00 AM 1/31/2010 8:51:00 AM 1/31/2010 8:50:01 AM