ScriptManager.RegisterClientScriptBlock不工作在asp.net [英] ScriptManager.RegisterClientScriptBlock is not working in asp.net

查看:292
本文介绍了ScriptManager.RegisterClientScriptBlock不工作在asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用ajax弹出即时通讯。显示无效用户aceess,然后重定向到home.aspx页,未经授权的用户其重定向到home.aspx页,但流行不表明非法访问。

我想说明的非法访问弹出,去home.aspx或者显示弹出,并在该网页不应该呈现什么

流行没有显示

 保护无效的Page_Load(对象发件人,EventArgs的)
    {
        如果(会话[LoginUser。的ToString()==管理员)
        {
            如果(!的IsPostBack)
            {

                如果(会话[登录ID] == NULL)
                {
                    的Response.Redirect(〜/的Login.aspx);

                }
                fillProj();
                fillYear();
                FillUser();
            }
        }
        其他
        {
            ScriptManager.RegisterClientScriptBlock(页的typeof(页),clentscript,警报('非法Accesss ..');,真正的);
            的Response.Redirect(Home.aspx);
        }
 

解决方案

试试这个

  this.RegisterStartupScript(舍克,<脚本>警报(非法Accesss ..'); parent.location.href ='Home.aspx'< /脚本>中);
 

  ScriptManager.RegisterClientScriptBlock(页的typeof(页),clentscript,警报('非法Accesss ..'); parent.location.href ='Home.aspx' , 真正);
 

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");
        }

解决方案

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);

这篇关于ScriptManager.RegisterClientScriptBlock不工作在asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆