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("O nClick",my Script)
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.findcont rol("btnPr int"),Html Button))
I'v tried doing...
myButton = ctype(me.controls("Form1") .controls. findcontro l("btnPrin t"),HtmlBu tton))
but that doesn't work either, they both return Nothing
So how do I get a reference to an HTML control?
myButton.attributes.add("O
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.findcont
I'v tried doing...
myButton = ctype(me.controls("Form1")
but that doesn't work either, they both return Nothing
So how do I get a reference to an HTML control?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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 =)
ASKER