?
Solved

page.findcontrol: input type="button"

Posted on 2007-07-24
2
Medium Priority
?
2,431 Views
Last Modified: 2013-11-26
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,
0
Comment
Question by:byrd48
2 Comments
 
LVL 9

Accepted Solution

by:
Chirag1211 earned 2000 total points
ID: 19562677
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
 
LVL 17

Expert Comment

by:Cem Türk
ID: 19563435
like this;
document.getElementById('btnAddGroup').setAttribute("style","display:none");
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question