I have an aspx webforms page with a repeater built through a user control. Each repeater item has a link button. What I want to happen is that when the LinkButton (in the repeater on page A's user control) is clicked, the url is opened in a new tab, and a hidden id next to that LinkButton is passed (according web development best practices for security if possible) to the aspx page (page B) in the new tab.
Both pages A and page B are in the same application.
The intent of what I described above is so that the user can easily return to their search results after returning from the URL opened by clicking on the LinkButton.
I am open to ideas on how to do this that are closer to standard best-practice methods.
So far, I have tried:
1) cross-page posting – this worked for passing the id, but not for opening in a new tab.
2) Setting the PostBackUrl to page B's url, setting the Page.Form.Target="_blank" with OnClientClick calling javascript to set the hidden id from the user control to the value of an html hidden input on page B and also.
3) I also tried using window.open("page B url", "_newtab") in OnClientClick.
-
a) So far, the only method that worked correctly was the 2nd one from the 3 different methods above.
However, after page B is loaded in the new tab, I don't know how to reset page A's Page.Form.Target back to what it was previously before setting it to "_blank" -
b) The methods that I have tried, to no avail, to reset the Page.Form.Target have been:
-
1) Resetting the target in page A's Page_Load where IsPostBack == true --> that caused Page B to load with the same content as Page A.
-
2) Resetting the target in page A's user control's Page_Load --> same result as method 1
-
3) Resetting the target in page A’s user control’s LinkButton’s OnUnLoad in page A's user control --> same result as method 1
-
4) Resetting the target in javascript through the LinkButton’s OnClientClick --> didn’t work
-
5) Resetting the target in page B's Page_Load using a public variable from page A containing a reference
to page A's form (similar to what can be done through cross-page posting) --> didn’t work.
What I am thinking about trying next is:
1) Wrapping another user control on page A to display page B's content, in an asp Panel (Panel B)
2) Put page B’s content into the new user control page
3) Wrapping the search results content on page A in an asp Panel (Panel A).
4) When the LinkButton in the repeater on the new user control is clicked, the search results content in Panel A will be hidden, and Panel B will be shown.
5) When the user wants to return to the search results, they will click on a ‘Return to Search’ LinkButton in Panel B’s content, and then Panel B will be hidden, then content of Panel B will be cleared, and Panel A will be shown again.
I'm not yet sure if that will work though.
It doesn't seem like this should be that difficult.
It is a straight-forward concept, and I would think is a fairly common situation in web development.
I feel like Wiley Coyote trying to catch the Road Runner because I come up with elaborate intelligent, thought-out plans that all completely fail.
I am now holding up a little sign that says, "Help!