468,468 Members | 2,690 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,468 developers. It's quick & easy.

Passing strings across webforms

Is there a way to pass strings from one webform to another without using
Response.Redirect( ) ? The reason is that I need the webform passing the
string to close its window.
Nov 16 '05 #1
1 2746

In this case, has the first window opened the second? You're then assigning
some value back to the opener window from the second window. Sort of
simulating the modal dialog situation in windows programming.

Say A opens window B...
Then in this case, then you need to:
- first pass the value from the B to A
- then refresh A from B
- before closing B
Request.QueryString
---------------------

If the string is short you can refresh A and pass in the information via a
query string i the URL using javascript.

(bForm.aspx.cs)
string dataString = "String to pass back";
StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.Append ( "<SCRIPT>" );
scriptBuilder.Append ( "windows.opener.location.href = 'aForm.aspx?data='" +
dataString + "'" );
scriptBuilder.Append ( "</SCRIPT>");
RegisterClientSideScript ( scriptBuilder.ToString() );

Then in the opener (aForm.aspx.cs) code, you can access this by calling
Request.QueryString["data"] in the Page_Load method.
Session object
---------------

Another way would be to replace the windows opener line with this:
(bForm.aspx.cs)
Session.Add ( "data", dataString )
....
// refresh the opener
scriptBuilder.Append ( "windows.opener.location.href =
windows.opener.location.href" );
....

then from aForm.aspx.cs in the Page_Load method, call
Session["data"] to get the data string back. Remember that if a session
object called data is found, it should probably be cleared in this case so
that each time the aForm reloads it doesn't think there's more data there.
If you're not opening windows using javascript script window.open then this
won't work, and the may problem is getting the second form to refresh the
first.

hope that helps.
Dan.
"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...
Is there a way to pass strings from one webform to another without using
Response.Redirect( ) ? The reason is that I need the webform passing the
string to close its window.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Tweaxor | last post: by
3 posts views Thread by Ivan Sammut | last post: by
1 post views Thread by Newbie | last post: by
2 posts views Thread by Jeremy | last post: by
22 posts views Thread by Arne | last post: by
8 posts views Thread by only_me | last post: by
17 posts views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.