1

im using ajax pop up . to show the invalid user aceess and then redirecting to home.aspx page, for unauthorised users its redirecting to home.aspx page but pop is not showing that illegal access.

i want to show pop up of illegal access and go to home.aspx or else show the pop up and should not render anything in that page

Pop is not showing

  protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["LoginUser"].ToString() == "admin" )
        {
            if (!IsPostBack)
            {

                if (Session["LoginId"] == null)
                {
                    Response.Redirect("~/Login.aspx");

                }
                fillProj();
                fillYear();
                FillUser();
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clentscript", "alert('Illegal Accesss..');", true);
            Response.Redirect("Home.aspx");
        }

4 Answers 4

2

Try this

this.RegisterStartupScript("scheck", "<script>alert('Illegal Accesss..'); parent.location.href='"Home.aspx'</script>");

Or

   ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clentscript", "alert('Illegal Accesss..'); parent.location.href='Home.aspx'", true);
Sign up to request clarification or add additional context in comments.

1 Comment

still its not showing pop - up , but redirecting to home.aspx page.
0

Use like below in your else condition.

ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Illegal Access...');window.location ='Home.aspx';", true);

1 Comment

@krishnasunlightit: you have not copied the code properly. it is working properly on my side. Copy properly and check again
0

Try this

 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clentscript", "alert('Illegal Accesss..'); parent.location.href='Home.aspx'", true);

Comments

0

Try this

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), 
                  "key", "alert('Illegal Access..')", true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.