By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

force asp button click event

P: 31
hi,
im dveloping a web system using vs 2008. in my page i have a ajax page method wich is called by javascript function . in onsuceeded method i want to force the save button on my page to be called and do the serverside finction in code behind "btnSave_Click(object sender, EventArgs e)" method.

I am calling this pagemethod function in onclientclick event of the save button.

depending on the result from the server side which is stored in result parameter which is passed to onsuceeded method, i want to call the "click" event of the save button.

how to call this click event of the buton using javascript?
Oct 15 '08 #1
Share this Question
Share on Google+
4 Replies


P: 55
as far as I know you can't fire an actual user event using javascript.

To elaborate:
you can call any event on any object AS a function e.g.

Expand|Select|Wrap|Line Numbers
  1. myEl.onmousedown()
but the default functionality of the click will not fire.

select boxes for instance will not open just because you fire the event on them, but if you set a function on the selectbox, that function will fire, but the selectbox will still not open.
Oct 16 '08 #2

P: 31
hi,
I tried with document.getElementById("<%=btnSave.ClientID%>").c lick();

but it is not working..

I am using masterpage in my system.
Oct 16 '08 #3

P: 55
try onclick() first of all, but like I was saying before...if this is a submit button for a form or something, the default functionality will not fire when you call it, you can only fire events that you have bound written functions to
Oct 16 '08 #4

P: 31
ok. i found the solution.

in my onsucceeded method i put

var btnName=$get("<%=btnSave.ClientID%>").name;
__doPostBack(btnName,"");

this fires the onClick serverside function .
Oct 16 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.