Tuesday, 29 July 2014

How to use DropDownList AutoPostBack in ASP.NET c#

How to use DropDownList AutoPostBack in ASP.NET c#
  1. <%@ Page Language=“C#” %>

  2. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

  3. <script runat=“server”>
  4.     protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
  5.     {
  6.         Label1.Text = “You Selected: “ + DropDownList1.SelectedItem.Text;
  7.     }
  8. </script>

  9. <html xmlns=“http://www.w3.org/1999/xhtml”>
  10. <head id=“Head1″ runat=“server”>
  11.     <title>How to use DropDownList AutoPostBack feature</title>
  12. </head>
  13. <body>
  14.     <form id=“form1″ runat=“server”>
  15.     <div>
  16.         <h2 style=“color:Navy”>DropDownList: AutoPostBack</h2>
  17.         <asp:Label
  18.              ID=“Label1″
  19.              runat=“server”
  20.              Font-Bold=“true”
  21.              ForeColor=“Purple”
  22.              Font-Size=“Large”
  23.              >
  24.         </asp:Label>
  25.         <br /><br />
  26.         <asp:Label
  27.              ID=“Label2″
  28.              runat=“server”
  29.              Font-Bold=“true”
  30.              ForeColor=“OrangeRed”
  31.              Text=“asp.net controls”
  32.              >
  33.         </asp:Label>
  34.         <asp:DropDownList
  35.              ID=“DropDownList1″
  36.              runat=“server”
  37.              AutoPostBack=“true”
  38.              OnSelectedIndexChanged=“DropDownList1_SelectedIndexChanged”
  39.              >
  40.              <asp:ListItem>HyperLink</asp:ListItem>
  41.              <asp:ListItem>PasswordRecovery</asp:ListItem>
  42.              <asp:ListItem>PlaceHolder</asp:ListItem>
  43.              <asp:ListItem>LoginName</asp:ListItem>
  44.              <asp:ListItem>Label</asp:ListItem>
  45.         </asp:DropDownList>
  46.     </div>
  47.     </form>
  48. </body>
  49. </html>



No comments:

Post a Comment