zoukankan      html  css  js  c++  java
  • 【转载】asp.net 后台弹出提示框

    感觉这种最好用:
    public void showMessage(string str_Message)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "结果", "alert('" + str_Message + "');", true);
                // Define the name and type of the client scripts on the page.
    
    
                String csname1 = "PopupScript";
                String csname2 = "ButtonClickScript";
                Type cstype = this.GetType();
                ClientScriptManager cs = Page.ClientScript;
                if (!cs.IsStartupScriptRegistered(cstype, csname1))
                {
                    String cstext1 = "alert('Hello World');";
                    cs.RegisterStartupScript(cstype, csname1, cstext1, true);
                }
                if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
                {
                    System.Text.StringBuilder cstext2 = new System.Text.StringBuilder();
                    cstext2.Append("<script type="text/javascript"> function DoClick() {");
                    cstext2.Append("Form1.Message.value='Text from client script.'} </");
                    cstext2.Append("script>");
                    cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
                }
    
    
                //ClientScript.RegisterClientScriptBlock(this.GetType(), "tishi", "<script type='text/javascript'>alert('你所查询的数据不存在!');</script>");
    
                //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "tishi","<script type='text/javascript'>alert('你所查询的数据不存在!');</script>");
                //ClientScriptManager scriptManager =((System.Web.UI.Page)System.Web.HttpContext.Current.Handler).ClientScript;
                //scriptManager.RegisterStartupScript(typeof(string), "", "alert('str_Message');", true);
                //scriptManager.RegisterStartupScript(typeof(string), "", "alert('str_Message');self.location='redirect'", true);
            }
     
     
    原文转载:http://www.cnblogs.com/luqian5588/p/3228225.html
     
     
     

    1.后台弹出提示信息方法

    Response.Write("<scripttype="text/javascript">alert('你所查询的数据不存在!');</script>");

    //弹出提示信息,但页面空白 Page.RegisterClientScriptBlock("tishi", "<scripttype="text/javascript">alert('你所查询的数据不存在');</script>");

    //弹出提示信息,但页面空白 Page.RegisterStartupScript("tishi", "<scripttype="text/javascript">alert('你所查询的数据不存在');</script>");//已过期,

    //弹出提示信息,页面不空白 ClientScript.RegisterClientScriptBlock(this.GetType(), "tishi","<script type="text/javascript">alert('你所查询的数据不存在!');</script>");

    //弹出提示信息,但页面空白 ClientScript.RegisterStartupScript(this.GetType(), "tishi","<script type="text/javascript">alert('你所查询的数据不存在!');

    </script>");

    //弹出提示信息,页面不空白
    //在vs2005中 需要引入System.Web.Extensions.dll ScriptManager.RegisterClientScriptBlock(this.btnTiShi, typeof(Button),"tishi", "alert('你所查询的数据不存在!');", true);

    //弹出提示信息,但页面空白 ScriptManager.RegisterClientScriptBlock(this, this.GetType(),"tishi", "alert('你所查询的数据不存在!');", true);

    //弹出提示信息,但页面空白,this表示page ScriptManager.RegisterStartupScript(this.btnTiShi, typeof(Button),"tishi", "alert('你所查询的数据不存在!');", true);

    //弹出提示信息,页面不空白 ScriptManager.RegisterStartupScript(Page,typeof(Page), "tishi","alert('你所查询的数据不存在!');", true);

    //弹出提示信息,页面不空白 ScriptManager.RegisterStartupScript(this, typeof(_Default), "tishi",script, true);

    //弹出提示信息,页面不空白,this表示page

    //后台获得confirm返回值,并有选择的执行语句块 C#端: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnTiShi.Attributes.Add("onclick","tishi()"); } }

    protected voidbtnTiShi_Click(object sender, EventArgs e) { if (this.hidevalue.Value == "1") { Response.Write("success"); } else { Response.Write("failue"); } }

    JS端: <script type="text/javascript"> function tishi() { if(confirm('你确定要删除吗?')) { document.getElementByIdx_x('hidevalue').value='1'; //window.location.href=window.location.href; } else { document.getElementByIdx_x('hidevalue').value='0'; } } </script>

  • 相关阅读:
    dpkg 被中断,您必须手工运行 sudo dpkg –configure -a 解决此问题
    运行wpscan报错Could not find 'nokogiri' (~> 1.8.0)
    理解:jar和war的区别
    AcWing3494. 国际象棋(状压DP)
    AcWing3422. 左孩子右兄弟(树形DP)
    python命名空间
    mysql日志大量报错“original commit timestamp is more recent than the immediate commit timestamp”
    python模块导入
    Centos-Docker镜像制作
    python面向对象之封装
  • 原文地址:https://www.cnblogs.com/jexwn/p/4524806.html
Copyright © 2011-2022 走看看