473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Invoking asp:button click in javascript

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...
Nov 18 '05 #1
2 9004
Take a look at the generated html on the client, and reverse engineer what
you need to do. It will emit an <input type="button" /> or <input
type="submit" />. Grab the ID (you can use the UniqueID property of the
Button object to emit this value, which future proofs your app) and then use
javascript to find the control and call the click method.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"JCE" <re***@ng.com> wrote in message
news:zn*******************@bignews5.bellsouth.net. ..
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...

Nov 18 '05 #2
JCE
Thank you for your reply.

I think I have tried every permutation of invoking the button click method
in javascript that I can find in the various newsgroups. I always get the
"Page Not Found" error page when the statement executes.

I've used: document.all("Button1").click(); where "Button1" is the ID for
an asp button.

....and document.Form2.Button2.click(); for an HTML INPUT button. (this
statement was built w/ intellisense, so seems legit.)

My app is straightforward, a WebUserControl in an WebForm, all built in .NET
using the visual tools, so don't think I've injected any wierdness into the
situation.

Perhaps you may see something in the syntax above that hints at the problem.
"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
Take a look at the generated html on the client, and reverse engineer what
you need to do. It will emit an <input type="button" /> or <input
type="submit" />. Grab the ID (you can use the UniqueID property of the
Button object to emit this value, which future proofs your app) and then use javascript to find the control and call the click method.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"JCE" <re***@ng.com> wrote in message
news:zn*******************@bignews5.bellsouth.net. ..
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...


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RSB | last post by:
Hi Every one, Having tuff time to make this work .. i want to have a button and on my form say Delete button. So once i click on it i want to confirm "Are you sure?" on the Client Side and if...
4
by: esoroka | last post by:
Hello, Trying to run a script what start ASP button: document.Form1.all.click(); It is work one time only. Next script ignore it. Where can be problem??? A full script is as follows:
2
by: giant food | last post by:
Hi, I'm writing an asp app. I have a text box with a validator and a submit button. Here is code from my .aspx file.... <asp:TextBox ID="txName" TextMode="SingleLine" Runat="server" />...
2
by: Ed Chiu | last post by:
Hi, I would like to add a <asp:button> to a webform. When user click on this button, the page will connect to SQL server and update tables, then the browser window will be closed. I know how...
1
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
3
by: JV | last post by:
This is for anyone who has tackled the accessibility issue on their web site (and if you haven't, I bet you will in future). Apparently the asp:button control always renders as '<input...
1
by: Praveen Ladwani | last post by:
I have written a click event for asp:button and I want to call a javascript function named setMethod() which I have wrtten seperately. Please tell me how to do this.
2
by: DFDavis | last post by:
I have a set of code that updates to a div tag through javascript whenever a checkbox is checked, however I need a way to get that information to the server side when the user uses the submit...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.