Problem with Update Panel [modified]
-
Hi Friends I am using Ajax in C#.NET. I have recently noticed that. I cannot fire Messagebox(Javascript-JS) if inside Update Panel. I am using Update Panel on my GridView. Only click of Delete Button i am firing one JS asking "Are You Sure" My Code LinkButton l = (LinkButton)e.Row.FindControl("lbtnDelete"); l.Attributes.Add("onclick", "javascript:return " + "confirm('Are You Sure You want to Delete ? ')"); The Above Code works perfectly. But then i make a DataBase Check if that Record is used anywhere else. So its like if(CheckRecord) Response.Write("<script>alert('Are you sure youw want to Continue?')</script>"); It doesnt work. i tired another dll for msgbox, which also doesnt work. I suspected for the Update panel. And i was right. If i remove the Update Panel both the options fire MessageBox for me. But i am using Edit,Delete,AddNew methods in GridView henceforth i need Update Panel. Now i have no Idea what should i do? Any solutions would be appreciated. Thanks -- modified at 8:22 Friday 2nd November, 2007
Cheers Menon
-
Hi Friends I am using Ajax in C#.NET. I have recently noticed that. I cannot fire Messagebox(Javascript-JS) if inside Update Panel. I am using Update Panel on my GridView. Only click of Delete Button i am firing one JS asking "Are You Sure" My Code LinkButton l = (LinkButton)e.Row.FindControl("lbtnDelete"); l.Attributes.Add("onclick", "javascript:return " + "confirm('Are You Sure You want to Delete ? ')"); The Above Code works perfectly. But then i make a DataBase Check if that Record is used anywhere else. So its like if(CheckRecord) Response.Write("<script>alert('Are you sure youw want to Continue?')</script>"); It doesnt work. i tired another dll for msgbox, which also doesnt work. I suspected for the Update panel. And i was right. If i remove the Update Panel both the options fire MessageBox for me. But i am using Edit,Delete,AddNew methods in GridView henceforth i need Update Panel. Now i have no Idea what should i do? Any solutions would be appreciated. Thanks -- modified at 8:22 Friday 2nd November, 2007
Cheers Menon
Menon, You cannot use Response.Write while using Microsoft AJAX, since the page will not postbacks fo your request. You can use Client Script of the Microsoft AJAX. Add handler for endRequest like below,
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(CheckRecordCallBack); CheckRecordCallBack(sender, arg){ if (args){ if (args.get_error()){ args.set_errorHandled(true); alert(args.get_error().message); } } }
You must throw the Message which you want to show after CheckRecord process from the CodeBehind. For more reference, read http://www.asp.net/ajax/documentation/live/ClientReference/default.aspx[^]
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
Menon, You cannot use Response.Write while using Microsoft AJAX, since the page will not postbacks fo your request. You can use Client Script of the Microsoft AJAX. Add handler for endRequest like below,
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(CheckRecordCallBack); CheckRecordCallBack(sender, arg){ if (args){ if (args.get_error()){ args.set_errorHandled(true); alert(args.get_error().message); } } }
You must throw the Message which you want to show after CheckRecord process from the CodeBehind. For more reference, read http://www.asp.net/ajax/documentation/live/ClientReference/default.aspx[^]
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot