posback后打开aspx页面 [英] Open aspx page after posback

查看:67
本文介绍了posback后打开aspx页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在使用以下代码根据GridView CheckBox Checked状态打开随机数的页面,但它只会打开最后一页.

Dear All,

I am using the following code to open random number of pages based on GridView CheckBox Checked Status but It only opens the last page.

string script = "<script>";
            foreach (GridViewRow row in gvM16Deductions.Rows)
            {
                chk = (CheckBox)row.FindControl("chkDeductionType");
                if (chk.Checked)
                {
                    string url = "../../Default5.aspx?m=" + cmbSDURN.SelectedValue + "&d=" + chk.ToolTip;
                    script += "window.open('"+url+"','window','toolbar=no,menubar=no,resizable=no,directories=no');";
                    //ClientScript.RegisterClientScriptBlock(typeof(string), "openPage" + chk.Text, "javascrit: openForm('" + cmbSDURN.SelectedValue + "','" + chk.ToolTip + "');");
                }
            }
            script += "</script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "openPage", script);



我做错了什么?
我无法打开所有页面,页面源中的脚本显示一切正常,但我不知道为什么只有最后一页才能打开?
还有一件有趣的事情,如果我给window.open(''pageadddress + querystring''),那么它将打开所有页面,但是我想使用param.



What am I doing wrong?
I can''t open all pages, the script from page source shows every thing is ok, but I dont know why only the last page opens?
One more interesting thing, if I give window.open(''pageadddress+querystring'') then it opens all pages, but I want to open it with param.

推荐答案

我在做什么错,我无法打开所有页面,页面来源的脚本显示一切正常,但是我不知道为什么只有最后一页打开了?
这是因为Window.Open方法中的第二个参数.
第二个参数是窗口的"名称".由于所有窗口都使用相同的名称(此处为固定名称),因此所有窗口都打开为同一窗口,因此最后一个窗口仍然存在.

在此处查看详细信息: MSDN:Window.Open [ ^ ]

解决方案:每次形成脚本时,都要更改窗口的名称.附加一个整数或任何其他容易找到的方式.
what am i doing wrong which i can''t open all pages, the script from page source shows every thing is ok, but I dont know why only the last page opens?
This is because of the 2nd parameter in the Window.Open method.
Second parameter is ''name'' of the window. Since you are using same name for all the windows (fixed name here), all open into same one and thus the last one persists.

Look at the details here: MSDN: Window.Open[^]

Resolution: Change the name of the window everytime you form the script. Append an integer or any other way you find easy.


我没有特定的主意,但是您可以通过更改代码来尝试.

I don''t have an specific idea, but you can try this by changing to your code.

            foreach (GridViewRow row in gvM16Deductions.Rows)
            {
                chk = (CheckBox)row.FindControl("chkDeductionType");
                if (chk.Checked)
                {
string script = "<script>";                    
string url = "../../Default5.aspx?m=" + cmbSDURN.SelectedValue + "&d=" + chk.ToolTip;
                    script += "window.open(''"+url+"'',''window'',''toolbar=no,menubar=no,resizable=no,directories=no'');";
                    //ClientScript.RegisterClientScriptBlock(typeof(string), "openPage" + chk.Text, "javascrit: openForm(''" + cmbSDURN.SelectedValue + "'',''" + chk.ToolTip + "'');");

            script += "</script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "openPage", script);
                }
            }


这篇关于posback后打开aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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