How to call ASP.NET server side button click event from javascript?( ASP.NET interview questions with answers)
- By Shiv Prasad Koirala in ASP.NET
- Nov 30th, 2013
- 15600
- 0
Yes it is. In reality there in web development world there is nothing called Event. What we have it requests and responses. Client will make either get or post request to server and server in response sent back pure HTML to client.
Now Microsoft had created a huge abstraction over this request-response Model and made it look like Event driven model.
Now in order to make a post request to server they internally implemented some client scripting code along with a js method called __doPostback.
function __doPostBack( eventTarget, eventArgument )
document.Form1.__EVENTTARGET.value = eventTarget;
document.Form1.__EVENTARGUMENT.value = eventArgument;
document.Form1.submit();
}
If we call this method passing name (not id) of the button as an argument, it will simply leads to post request to server and Button_Click event get raised in server side.
(Second argument is - additional data associated with the control)
You can also watch this ASP.NET interview questions with answer video on Authentication and Authorization.
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more