Solved

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

Posted on 2009-05-18
4
764 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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 …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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