Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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