Default Button Demo : Default Button « Asp Control « ASP.Net






Default Button Demo

<%@ Page Language="C#" %>
<script runat="server">
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        lblResult.Text = "Search for: " + txtSearch.Text;
    }
</script>
<html>
<head>
    <title>Button Default Button</title>
</head>
<body>
    <form id="form1" defaultbutton="btnSearch" runat="server">
    <div>
    
    <asp:Label
        id="lblSearch"
        Text="Search:"
        AssociatedControlID="txtSearch"
        Runat="server" />
    <asp:TextBox
        id="txtSearch"
        Runat="server" />
    <asp:Button
        id="btnSearch"
        Text="Search"
        OnClick="btnSearch_Click"
        Runat="server" />
    <asp:Button
        id="btnCancel"
        Text="Cancel"
        Runat="server" />    
    
    <hr />
    
    <asp:Label
        id="lblResult"
        Runat="server" />
    
    </div>
    </form>
</body>
</html>

           
       








Related examples in the same category