Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 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