Javascript call
-
Hi Guys, i am a bit new to ASP .net web development. I have created a user control and placed some radio buttons, now i want to call a javascript function on the OnCheckedChanged event of the radio button. I googled but to no use. Also on my web page if i try to call a javascript it gives me error. Can anyone please tell me the correct way to call javascript in both the cases. Thanks in advance,
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
-
Hi Guys, i am a bit new to ASP .net web development. I have created a user control and placed some radio buttons, now i want to call a javascript function on the OnCheckedChanged event of the radio button. I googled but to no use. Also on my web page if i try to call a javascript it gives me error. Can anyone please tell me the correct way to call javascript in both the cases. Thanks in advance,
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
Solution for OnCheckedChanged event of the radio button. check with ClientScript.RegisterClientScriptBlock e.g.[ some pseudo code]
public void ShowMessage(string input) {
string strScript = String.Empty;
strScript =@"<script language=javascript> ";
strScript = strScript + "alert('"+input+"')";
strScript = strScript + @"</script>";
RegisterClientScriptBlock("clientScript", strScript);
}protected void rdButton_OnCheckedChanged(object sender, EventArgs e)
{
ShowMessage("Niladri Showed a way to solve the problem");
}Check for the next part, add <pre><script language="javascript" type="text/javascript"></pre> If not you are making any mistake it is guarented to work. Vote please :)
Niladri Biswas
-
Hi Guys, i am a bit new to ASP .net web development. I have created a user control and placed some radio buttons, now i want to call a javascript function on the OnCheckedChanged event of the radio button. I googled but to no use. Also on my web page if i try to call a javascript it gives me error. Can anyone please tell me the correct way to call javascript in both the cases. Thanks in advance,
Thanks & Regards, Pramod "Everyone is a genius at least once a year"
Yadav Pramod wrote:
now i want to call a javascript function on the OnCheckedChanged event of the radio button.
OnCheckedChanged
is a server side event and fires only whenAutoPostBack
is turned on. So hooking a JS function from here is pointless. I guess you want to call a JS function when someone clicks on theCheckBox
, right? Use the Attributes[^] property to add aonClick
attribute. Something likeYourCheckBox.Attributes.Add("onClick","JsFunction();")
Do this on the page load, so that your checkbox renders with this attribute andJsFunction()
will get called when user clicks on the checkbox. :)Navaneeth How to use google | Ask smart questions
-
Yadav Pramod wrote:
now i want to call a javascript function on the OnCheckedChanged event of the radio button.
OnCheckedChanged
is a server side event and fires only whenAutoPostBack
is turned on. So hooking a JS function from here is pointless. I guess you want to call a JS function when someone clicks on theCheckBox
, right? Use the Attributes[^] property to add aonClick
attribute. Something likeYourCheckBox.Attributes.Add("onClick","JsFunction();")
Do this on the page load, so that your checkbox renders with this attribute andJsFunction()
will get called when user clicks on the checkbox. :)Navaneeth How to use google | Ask smart questions