使用c#在asp.net中的Request.querystring和Popup窗口. [英] Request.querystring and Popup window in asp.net with c#.

查看:34
本文介绍了使用c#在asp.net中的Request.querystring和Popup窗口.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将选定的gridview行(在Page1.aspx中)传递给Page2.aspx的文本框.我正在检索Page2.aspx的pageload事件中选定行的值.现在我在Page2.aspx中具有更改按钮.更改按钮,打开一个新的asp.net页面(Page3.aspx).我正在使用javascript Window.open()函数打开Popup窗口.我没有从page2.aspx向page3.aspx发送任何信息. > 现在在Page3.aspx中,我有一些过滤器,基于加载网格中的哪些数据以及使用会话变量将选定的网格行传输到page2.aspx.
问题是当我单击按钮"以打开Page3.aspx,然后再次刷新Page2时,它在request.querystring中抛出异常Index Out Of Exception.
如何解决此问题????????????目前没有传递QueryString.以下方法将解决您的问题:

1)我认为您正在遍历QuesryString集合.在执行此操作之前,请检查是否为null.

2)在按钮的OnClientClick上编写JavaScript(以打开弹出窗口).函数的最后一行是return false;

 功能 openPopup()
{
  ...
  窗口 .open(\ "  




并以这种方式调用此函数:

 <   asp:Button     ID   ="     runat   =" 服务器" 文本  按钮"  OnClientClick   ="    / >  


希望这会有所帮助!


I am passing selected rows of gridview (in Page1.aspx)to Textboxes Of Page2.aspx.I am retrieving values of selected rows in pageload event of Page2.aspx .Now I have button CHANGE in Page2.aspx.On clicking Button CHANGE, a new asp.net page (Page3.aspx) is opened .I am using javascript Window.open() function to open PopUp window.I am not sending any information from page2.aspx to page3.aspx.
Now in Page3.aspx,I have some filters based on which data in grid is loaded and selected rows of grid is now transfered to page2.aspx using session variables.
Problem is when I click Button to open Page3.aspx, then Page2 is refreshed again and it throws an exception Index Out Of Exception in request.querystring.
how to solve this problem???

解决方案

Clicking the button "Change" in Page2.aspx does a postback. At this time NO QueryString is passed. The following methods will solve your issue:

1) I think you are iterating through QuesryString collection. Do a check for null before doing that.
OR
2) Write JavaScript (to open the popup window) on OnClientClick of the button. The last line of the function would be return false;

function openPopup()
{
  ...
  window.open(\"url\");
  return false;
}




And call this function this way:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return openPopup()" />


Hope this helps!


这篇关于使用c#在asp.net中的Request.querystring和Popup窗口.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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