problem with update panel and javascript
-
Hi All, I have some problem with javascript. when I use update panel then this problem comes. when i click on Button1 first time, then some error occurs. but next time it not comes. it may be some script register problem. but i reister the javascript function in Page_Load event on button click. i ma very confused, why this error coming. i search many on this but not found any solution. please help me. here is sample code . i also did like this.. i write this code on button click protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); } protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return msgg();"); } in aspx I write this-- thanks.
-
Hi All, I have some problem with javascript. when I use update panel then this problem comes. when i click on Button1 first time, then some error occurs. but next time it not comes. it may be some script register problem. but i reister the javascript function in Page_Load event on button click. i ma very confused, why this error coming. i search many on this but not found any solution. please help me. here is sample code . i also did like this.. i write this code on button click protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); } protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return msgg();"); } in aspx I write this-- thanks.
i write aspx code thanks.
-
Hi All, I have some problem with javascript. when I use update panel then this problem comes. when i click on Button1 first time, then some error occurs. but next time it not comes. it may be some script register problem. but i reister the javascript function in Page_Load event on button click. i ma very confused, why this error coming. i search many on this but not found any solution. please help me. here is sample code . i also did like this.. i write this code on button click protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); } protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return msgg();"); } in aspx I write this-- thanks.
Register your script on page load event. OR you can try this: protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); Button1.Attributes.Add("onClick", "return msgg();"); } protected void Page_Load(object sender, EventArgs e) { //Button1.Attributes.Add("onClick", "return msgg();"); }
/***********************/ Parwej Ahamad g.parwez@gmail.com /***********************/
modified on Tuesday, March 4, 2008 10:35 PM
-
Register your script on page load event. OR you can try this: protected void Button1_Click(object sender, EventArgs e) { string scriptString = "function msgg() { alert('hello');}"; ScriptManager.RegisterStartupScript(this ,typeof (UpdatePanel), "scriptString", scriptString, true); //i tried these also.. //ScriptManager.RegisterStartupScript(Button,typeof (Button1), "scriptString", scriptString, true); //ScriptManager.RegisterStartupScript(updatepanelid ,typeof (UpdatePanel), "scriptString", scriptString, true); Button1.Attributes.Add("onClick", "return msgg();"); } protected void Page_Load(object sender, EventArgs e) { //Button1.Attributes.Add("onClick", "return msgg();"); }
/***********************/ Parwej Ahamad g.parwez@gmail.com /***********************/
modified on Tuesday, March 4, 2008 10:35 PM
thanks Parwej. i did like this as you told. now wrror is not coming but when I click first time nothing happen. i mean javascript function not run. but second time it runs. can you give me any solution. thanks
-
thanks Parwej. i did like this as you told. now wrror is not coming but when I click first time nothing happen. i mean javascript function not run. but second time it runs. can you give me any solution. thanks
Did you registered on page load event ?
Parwej Ahamad g.parwez@gmail.com
-
Did you registered on page load event ?
Parwej Ahamad g.parwez@gmail.com
no. i remove from there. is it need. thanks
-
Did you registered on page load event ?
Parwej Ahamad g.parwez@gmail.com
on button click event i fetch some data from databse base and then i use this data in javascript function, then i register this. i think when i will register on page load it will not work properly. thanks
-
on button click event i fetch some data from databse base and then i use this data in javascript function, then i register this. i think when i will register on page load it will not work properly. thanks
Ok, I got your point You can do with hidden controls or session variable. When you clicked on button set the value in hidden variable or session variable and then access that variable in javascript function with the help getElementById method.
Parwej Ahamad g.parwez@gmail.com