Solved

forcing a page postback to reload the page and keep current information

Posted on 2009-05-18
4
763 Views
Last Modified: 2012-05-07
Hi All,
Is it possible to force a page to postback and keep its viewstate?

The long version of the problem is:
I have a page where the user selects several values of things in controls for a report and then clicks a button. The code behind the button event takes the controls values and builds up a querystring which is then passed to a report component.

I have to open the report in a new window so i use this code:
Response.Write("<script>");
Response.Write("window.open(\"/ReporterMaker/makereport.asp?" + strReportParams + "\")");
Response.Write("</script>");

This all works fine until I noticed that this javascrtipt prevents the 3rd party javascript menu we are using. I cant debug the problem with the menu so i dont know whats going on there. So I reckon if I just postback it should solve the problem.

Thanks in advance.
O
0
Comment
Question by:osion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 24411901
Page.ClientScript.RegisterStartupScript(this.GetType(), "ForcePostback", this.ClientScript.GetPostBackEventReference(this.YourControlNameToPostBAck), true);
0
 

Author Comment

by:osion
ID: 24411997
Hi there crazyman,
thanks for the answer!
will that postback once the control is clicked?
i kinda need to do the postback after i ve printed the script stuff in the code behind
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 250 total points
ID: 24412214
>>This all works fine until I noticed that this javascrtipt prevents the 3rd party javascript menu we are using.

Just a hunch but..the code you posted might be breaking the menu script because you are using Response.Write.
Response.Write will write the text out before anything and everything...so the output is technically broken html because it would look something like:
<script>
window.open
</script>
<html>
the rest
</html>

Your code you added using Response.Write isn't part of the html document at all...

Try using RegisterStartupScipt to add your window.open...this actually puts the script into the <head> section where it belongs...

Page.ClientScript.RegisterStartupScript(this.GetType(), "LoadReport", "window.open(\"/ReporterMaker/makereport.asp?" + strReportParams + "\")", true);
0
 

Author Closing Comment

by:osion
ID: 31582582
Thats exactly it! :)
I thought there might be another way to do that but wasnt sure!
Thanks a million..
O
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question