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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Rakrus106 reputationPosted Feb 29, 2008, 4:51 AM EST
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="";
}
}
sabarish Govindan6 reputationPosted Mar 1, 2008, 1:17 AM EST
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?
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Mar 1, 2008, 11:31 PM EST
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>