Invoking asp:button click in javascript

J

JCE

I need to programmatically invoke an asp:Button click event from a
javascript function. The page containing the script and the button is the
HTML page associated with a WebUserControl-derived object (both the HTML and
control are built in the same .ascx file)

The target button simply fires an event in the WebUserControl-derived
object. So, alternatively, if there was a mechanism to call a method
(explicitly or using an event of some sort) in the WebUserControl-derived
object, from this javascript function - this would achieve the goal too,
with one less degree of indirection..

Seems so simple, but I've searched the newsgroups for hours...


(repost, posted to .aspnet, never showed up - reposted here since webcontrol
related.)
 
K

Ken Cox [Microsoft MVP]

Could you post a simple version of the code that you have so far? It doesn't
seem like it should be necessary to use script to simulate a button click.
 
J

JCE

Solution for other readers:

Use 'Page.GetPostBackEventReference(<button_member_name>)' in your Page_Load
method to get a string describing the javascript needed to invoke the click,
then use that string in your javascript. Works...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,224
Latest member
Gwen068088

Latest Threads

Top