Link to home
Start Free TrialLog in
Avatar of useless_eater
useless_eater

asked on

I can't find an HTML Button with the Controls.FindControl method!

I have an HTML button on my page opposed to an ASP.Net server control as I don't want the form to be posted back when I click on it.  In the form load event I want to add a bit of javascript using the attributes collection e.g.

myButton.attributes.add("OnClick",myScript)

I'm trying to get a reference to the HTML button control using the FindControl method but this can't seem to find the button on my page e.g.

myButton = ctype(me.controls.findcontrol("btnPrint"),HtmlButton))

I'v tried doing...

myButton = ctype(me.controls("Form1").controls.findcontrol("btnPrint"),HtmlButton))

but that doesn't work either, they both return Nothing

So how do I get a reference to an HTML control?
SOLUTION
Avatar of tusharashah
tusharashah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of useless_eater
useless_eater

ASKER

I'll try that and report back.  But I'd still like to know if I can find an html control.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm adding the control at design time.

Having looked at your example b1xml2 I realise my mistake, I forgot to put the runat=server property in my tag.  It's finding it now.

so all is well then =)