Find an HTML control in VB code

  • Thread starter Thread starter Lloyd Sheen
  • Start date Start date
L

Lloyd Sheen

I have to use WebMatrix so I cannot debug these pages. I have an HTML
button which I need to find on the page_load event. The FindControl will
not find it at least from page.findcontrol.

Is there any way to do this??

Lloyd Sheen
 
Lloyd, I only did a quick test, but I was able to find this button with page.findcontrol()..

<input type="button" value="Push Me" id="myButton" runat="server"

....but not without runat=server. Sorry I don't know anything about WebMatrix; not sure if it allows you to get at that or not

----- Lloyd Sheen wrote: ----

I have to use WebMatrix so I cannot debug these pages. I have an HTM
button which I need to find on the page_load event. The FindControl wil
not find it at least from page.findcontrol

Is there any way to do this?

Lloyd Shee
 
Yeah, you should be able to find it using Page.FindControl("controlid"). What's syntax are you using

It should be something like this

TextBox objTB = (TextBox) Page.FindControl("mytextbox1")
if(objTB != null) Reponse.Write(objTB.Text)

Suresh

----- Bill Borg wrote: ----

Lloyd, I only did a quick test, but I was able to find this button with page.findcontrol()..

<input type="button" value="Push Me" id="myButton" runat="server"

...but not without runat=server. Sorry I don't know anything about WebMatrix; not sure if it allows you to get at that or not

----- Lloyd Sheen wrote: ----

I have to use WebMatrix so I cannot debug these pages. I have an HTM
button which I need to find on the page_load event. The FindControl wil
not find it at least from page.findcontrol

Is there any way to do this?

Lloyd Shee
 
With runat server it seems the control is there at the page_load time. Is
there any other event where the controls have been rendered and property can
be changed.

WebMatrix is just a more advanced editor than notepad. I am sure there are
people writing ASP.NET code without VS.

Lloyd

Bill Borg said:
Lloyd, I only did a quick test, but I was able to find this button with page.findcontrol()...

<input type="button" value="Push Me" id="myButton" runat="server">

...but not without runat=server. Sorry I don't know anything about
WebMatrix; not sure if it allows you to get at that or not.
 
I created a routine that enumerated every control and the HTML controls all
have no ID set.

FindControl does not work either most likely for the reason that no control
with the ID is present at page_load. Viewing the HTML after the page is
rendered provides the fact that at that time there is a button with the ID I
am looking for. By then it is too late.

Lloyd Sheen

Suresh said:
Yeah, you should be able to find it using Page.FindControl("controlid"). What's syntax are you using?

It should be something like this.

TextBox objTB = (TextBox) Page.FindControl("mytextbox1");
if(objTB != null) Reponse.Write(objTB.Text);

Suresh.

----- Bill Borg wrote: -----

Lloyd, I only did a quick test, but I was able to find this button with page.findcontrol()...

<input type="button" value="Push Me" id="myButton" runat="server">

...but not without runat=server. Sorry I don't know anything about
WebMatrix; not sure if it allows you to get at that or not.
 
Putting the runat does the trick. Thanks.
ASP.NET - proof that Computer Science is an oxymoron.

Lloyd
Bill Borg said:
Lloyd, I only did a quick test, but I was able to find this button with page.findcontrol()...

<input type="button" value="Push Me" id="myButton" runat="server">

...but not without runat=server. Sorry I don't know anything about
WebMatrix; not sure if it allows you to get at that or not.
 
Back
Top