Showing posts with label Servercontrol. Show all posts
Showing posts with label Servercontrol. Show all posts

Monday, March 7, 2011

To use button control as HTML server control in asp.net


HTMLServerControl.aspx

<%@ Page Language="C#" %>
<script runat="server">  
    protected void Button1_ServerClick(object sender, System.EventArgs e)  
    {  
        Label1.Text = "Hi! " + TextBox1.Text;  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml" >  
<head id="Head1" runat="server">  
    <title>How to use button control as HTML server control in asp.net</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Navy; font-style:italic;">HTML Server Control Example: Using Button</h2>  
        <asp:Label   
            ID="Label1"   
            runat="server"  
            Font-Bold="true"  
            ForeColor="DodgerBlue"  
            Font-Size="Larger"  
            >  
        </asp:Label>  
        <br /><br />  
        <asp:Label   
            ID="Label2"   
            runat="server"  
            Text="Name"  
            Font-Bold="true"  
            ForeColor="DeepPink"  
            >  
        </asp:Label>  
        <asp:TextBox   
            ID="TextBox1"  
            runat="server"  
            BackColor="PaleGoldenrod"  
            ForeColor="DeepPink"  
            >  
        </asp:TextBox>  
        <br />  
        <input   
            type="button"   
            id="Button1"   
            value="Submit"   
            runat="server"   
            onserverclick="Button1_ServerClick"   
            />  
    </div>  
    </form>  
</body>  
</html>