Groups | Blog | Home
all groups > asp.net > february 2004 >

asp.net : Search For An HTML Tag


Jim Heavey
2/21/2004 7:54:03 PM
If I have a <div id='fred' runat='server'> embedded in my HTML page, how
Ken Cox [Microsoft MVP]
2/21/2004 11:47:25 PM
Hi Jim,

You can create an instance of the HTMLGenericControl, get a handle on your
div and mess with the properities as shown below. Is this what you need?

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim divHTML As _
System.Web.UI.HtmlControls.HtmlGenericControl
divHTML = Page.Controls(1).FindControl("fred")
divHTML.Attributes.Add("Style", "COLOR: red")
End Sub

<form id="Form1" method="post" runat="server">
<div id='fred' runat='server'>Change Colour</div>
<asp:Button id="Button1" runat="server" Text="Change"></asp:Button></DIV>
</form>

Ken
Microsoft MVP [ASP.NET]
Toronto

[quoted text, click to view]
AddThis Social Bookmark Button