Find An HTML Control

Find An HTML Control

am 16.01.2008 16:59:03 von OldButStillLearning

How do you find an HTML control that is placed on an HTML page? I presume
that you have to add the runat="server" to the HTML element..but then how do
you find that element?

Re: Find An HTML Control

am 16.01.2008 17:42:34 von Leon Mayne

"OldButStillLearning" wrote
in message news:D5BA6B99-FCB6-423D-A41D-ABED80B6A018@microsoft.com...
> How do you find an HTML control that is placed on an HTML page? I presume
> that you have to add the runat="server" to the HTML element..but then how
> do
> you find that element?

If you add runat="server" then you can access it using its Id:

Default.aspx:





Hello!


Default.aspx.vb:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
tblMyTable.Border = 1
End Sub

Re: Find An HTML Control

am 16.01.2008 17:57:23 von Scott Roberts

Give it an ID="MyControl".

Then you can "find" it by using the FindControl() method. Or, just access it
directly:

MyControl.Style = "color: red;"


"OldButStillLearning" wrote
in message news:D5BA6B99-FCB6-423D-A41D-ABED80B6A018@microsoft.com...
> How do you find an HTML control that is placed on an HTML page? I presume
> that you have to add the runat="server" to the HTML element..but then how
> do
> you find that element?
>
>

Re: Find An HTML Control

am 16.01.2008 19:25:32 von Steve

As an alternative to the fine suggestions already given to you, a basic
recursion routine can sometimes be useful for finding controls of interest
on the current form. Here's more info:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
http://iPhonePlaza.net


"OldButStillLearning" wrote
in message news:D5BA6B99-FCB6-423D-A41D-ABED80B6A018@microsoft.com...
> How do you find an HTML control that is placed on an HTML page? I presume
> that you have to add the runat="server" to the HTML element..but then how
> do
> you find that element?
>
>