Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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???
Posted
Updated 25-Jun-10 23:33pm
v2

1 solution

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;
JavaScript
function openPopup()
{
  ...
  window.open(\"url\");
  return false;
}



And call this function this way:
XML
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return openPopup()" />

Hope this helps!
 
Share this answer
 
v3
Comments
akkanshagupta 26-Jun-10 6:25am    
I tried this but got the same problem again.As son as i click button CHANGE to open Page3.aspx, it opens but when any postback occurs in page3.aspx,it will refresh the page2.aspx.Hence causing same exception for querystring.please tell me another option.
Ankur\m/ 26-Jun-10 7:10am    
akkanshagupta wrote: "but when any postback occurs in page3.aspx,it will refresh the page2.aspx."
WHY??
Anyways, try the 1st option then i.e check the QueryString for null values before using it.
Something like:
if(Request.QueryString[i] != null)
{
//get values from querystring.
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900