Solved

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

Posted on 2009-05-18
4
758 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
  • 2
4 Comments
 
LVL 13

Expert Comment

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

Author Comment

by:osion
Comment Utility
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
Comment Utility
>>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
Comment Utility
Thats exactly it! :)
I thought there might be another way to do that but wasnt sure!
Thanks a million..
O
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now