Page does not redirect
-
Dear all, I am using asp.net2.0, C#, ajax1.0 Now there is requirement where I have to check user where he has access to this side it not then show the message and return to default page Now I am trying with this code Define a method in a class as public void ShowMsg(string msg, Page p) { String csname1 = "PopupScript"; Type cstype = this.GetType(); String cstext1 = "alert(' " + msg + "');"; ScriptManager.RegisterClientScriptBlock(p, cstype, csname1, cstext1, true); } then call this method as Doctor drck = new Doctor(); drck.ShowMsg("Access denied", this.Page); and redirect it as Response.Redirect("~/HTML/writeup.aspx"); Now issue is page does not redirect to specified path if I comment message then page redirect What problem with the code If any better idea, please suggest Thank you imran khan
-
Dear all, I am using asp.net2.0, C#, ajax1.0 Now there is requirement where I have to check user where he has access to this side it not then show the message and return to default page Now I am trying with this code Define a method in a class as public void ShowMsg(string msg, Page p) { String csname1 = "PopupScript"; Type cstype = this.GetType(); String cstext1 = "alert(' " + msg + "');"; ScriptManager.RegisterClientScriptBlock(p, cstype, csname1, cstext1, true); } then call this method as Doctor drck = new Doctor(); drck.ShowMsg("Access denied", this.Page); and redirect it as Response.Redirect("~/HTML/writeup.aspx"); Now issue is page does not redirect to specified path if I comment message then page redirect What problem with the code If any better idea, please suggest Thank you imran khan
use session... to store your message, and after redirecting, you need to show the message from session to the document. If you are writing the alert on the same page, it will not work. Rather you can call alert in writeup.aspx. Its better practice
Abhishek Sur
-
Dear all, I am using asp.net2.0, C#, ajax1.0 Now there is requirement where I have to check user where he has access to this side it not then show the message and return to default page Now I am trying with this code Define a method in a class as public void ShowMsg(string msg, Page p) { String csname1 = "PopupScript"; Type cstype = this.GetType(); String cstext1 = "alert(' " + msg + "');"; ScriptManager.RegisterClientScriptBlock(p, cstype, csname1, cstext1, true); } then call this method as Doctor drck = new Doctor(); drck.ShowMsg("Access denied", this.Page); and redirect it as Response.Redirect("~/HTML/writeup.aspx"); Now issue is page does not redirect to specified path if I comment message then page redirect What problem with the code If any better idea, please suggest Thank you imran khan
Use javascript to redirect instead of using response.redirect for eg.. Sub Show_Msg() Dim scp As String = "alert('Access denied ');window.location.href='~/HTML/writeup.aspx'" ClientScript.RegisterClientScriptBlock(Me.GetType(), "script1", scp) End Sub I am not sure whether the "~" sign works in javascript or no.You might have to change it accordingly.
When you fail to plan, you are planning to fail.