Find An HTML Control
am 16.01.2008 16:59:03 von OldButStillLearningHow 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?
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?
"OldButStillLearning"
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
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"
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?
>
>
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"
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?
>
>