Hi all,
I have a web form, which contains some event such as button1_click to process something. Here i want to execute the button1_click event functionality from javascript, may its possible. please advice me
Thanks in advance
Hi all,
I have a web form, which contains some event such as button1_click to process something. Here i want to execute the button1_click event functionality from javascript, may its possible. please advice me
Thanks in advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Mar 2, 2008, 4:31 AM
You take the html button,if u want to execute your button in client side.Or dont add the attribute runat ="server".You call the javascript function on button onclick event.So the button execution will occur in client side. it will not go to server side.Hence postback will not happen.
i.e.
now call the btnClick function in java script.
<
script type="text/javascript">function
btnClick(){
}
script>sabarish GovindanPosted Mar 1, 2008, 6:17 AM
Hi,
When i try this code page get postback while the time of calling server event, but my scenario here is to call the javascript function without postback. how i can acheive this?
RakrusPosted Feb 29, 2008, 9:51 AM
Hi try this,
function somefunctio()//some function to execute server side code
{
document.all["hdnVariable"].value="Somevalue";
//don't forget to set runat=server for the hidden variable
document.forms[0].submit();
}
//code behind in the page load
Page_Load()
{
if(hdnVariable.value=="value setted in the client side")
{
Button1_Click(eventArgs.Empty); //(or) Logic in the function Button1_click goes here
hdnVariable.value="";
}
}