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!

Comments (7) -

Mocmed United States
9/15/2011 7:26:13 AM #

Great ....You have beautifully presented your thought in this blog post.

polyurethane finish
polyurethane finish United States
10/1/2011 1:04:22 AM #

Greetings! This is a reallylvery good website.

riad Marrakech
riad Marrakech France
10/12/2011 7:11:50 PM #

Venerate to stipulation writer , few renowned particular tidings . “When you terminate to wish you terminate to vivid.” by Malcolm Stevenson Forbes.

Fred United States
10/17/2011 7:29:16 PM #

Merci pour ce post.

Windows Hosting  M6.Net
Windows Hosting M6.Net United States
10/20/2011 7:08:12 PM #

Great post. Interesting story to get involved.


Web Directory
Web Directory United States
11/3/2011 6:48:40 AM #

Super-Duper web site! I’m loving it!! Will come back once more – taking you feeds also, Thanks.

paiement sur internet
paiement sur internet France
11/6/2011 11:10:41 PM #

Merci pour ces informations, je recherchais un truc du genre depuis pas mal de temps. Encore merci Smile


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