page.findcontrol: input type="button"

page.findcontrol: input type="button"

Hi,
I have an html button on an asp.net page and wish to add attributes to it at runtime.  With a server control, I would just use mycontrol.attributes.add(..).
However, in this case, I do not want the button to post back, only to call a javascript function, so I elected for an html button.
However, the issue I'm running into is setting the attributes at page_load.
I am unable to find the control using something like:

dim myBtn as HtmlInputButton = ctype(page.findcontrol("btnAddGroup"),HtmlInputButton)

The button is declared as follows:

<input id="btnAddGroup" type="button" value=">>" class="btn" />

How can add attributes to this control at runtime?
Thanks,
byrd48Asked:
Who is Participating?
 
Chirag1211Commented:
The problem here is you need to add runat=server attribute in your input tag as follows:

input id="btnAddGroup" type="button" value=">>" class="btn"  runat=server/>

This will allow you get the object in Codebehind filw where you can do attributes.add()

Regards,

Chirag Patel.
0
 
Cem TürkSenior Software EngineerCommented:
like this;
document.getElementById('btnAddGroup').setAttribute("style","display:none");
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.