Set HTML Attributes for Controls in ASP.NET

by Kareem Allam 2. August 2011 01:00

You can set HTML Attributes for any ASP.Net Controls and use it in code to use control value


Set HTML Attributes for Any Controls 

HTML Side 

<body id="body" runat="server">
    <form id="form1" runat="server">
       <input runat="server" id="Button1" type="button"/>




Code Side (


Private Sub Page_Load(ByVal sender As System.Object, _
                     ByVal e As System.EventArgs) Handles MyBase.Load
        Button1.Attributes.Add("onclick", "alert('Message')")
        body.Attributes("bgcolor") = "black"

    End Sub


If you enjoyed this post, make sure you subscribe to my RSS feed!


If you would like to find value services with excellent quality and cost effectiveness and with a focus on speed , Just Follow

 Egypt Development Freelance Team.

Month List

Page List