如何处理在Ajax中用Response.write()

来源:互联网 发布:合影软件 编辑:程序博客网 时间:2024/05/20 05:25

ScriptManager.RegisterStartupScript(this.Button1, this.GetType(), "alertScript", "window.open('default2.aspx');", true);
其中第一个参数为要注册脚本的控件ID,试了一下,只要是本页面的就行。
第二个参数为注册脚本控件类型,是控件还是this的GetType()都可以,typeOf(string)也没问题.
第三个脚本函数的名字,随便起。
第四个是脚本内容。
第五个是标明是否再添加脚本标签,如果第四个参数里包含了 <script> </script>标签,此处则为false,否则为true。


 //确定
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string name = "";
        string id = "";
        TreeNodeCollection node = this.TreeView1.CheckedNodes;
        foreach(TreeNode item in node)
        {
            if(item.Checked==true)
            {
                if (item.Value.Substring(0,1)=="X")
                {
                    if (name == "" && id == "")
                    {
                        name = item.Text;
                        id = item.Value;
                    }
                    else
                    {
                        name = name + "," + item.Text;
                        id = id + "," + item.Value;
                    }
                }
            }
        }
        string str = "window.returnValue='"+name+"@"+id+"';window.close()";
        ScriptManager.RegisterStartupScript(this.btnOK, this.GetType(), "pringStr", ""+str+"", true);

    }

原创粉丝点击