Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Is it possible to read a textbox control from another web form?

Reply
Thread Tools

Is it possible to read a textbox control from another web form?

 
 
Paul Hale
Guest
Posts: n/a
 
      10-28-2003
Hi,

I have two web forms (lets call them webform1 and webform2) that run
as part of the same web application.

Webform1 contains a text box. I would like to pop up a new browser
window (containing webform2) and read the contents of the text box in
webform1 and display in webform2.

Is it possible to do this without posting the contents in a form or
over http or setting up a cache.

Ie - Something like declaring the text box public in webform1 and
then...

(Code in webform 2)

dim objWebForm1 as webform1)
response.write(objWebForm1.mytextbox.text)

Hopefully you get what im trying to do!

Thanks for any help!

Paul.
 
Reply With Quote
 
 
 
 
Stephan Bour
Guest
Posts: n/a
 
      10-28-2003
One ugly way to do it is to use Response.Redirect and embed the textbox.Text
string into the URL for the webform 2.

A more elegant way is to use Session State. Here is an example that assumes
the ID of your text box is TextBox (code behind in C#).

if (Session["Form1"] == null) {
Form1 = new FormEntry();
Session["Form1"] = Form1;
}
else {
Form1 = (FormEntry) Session["Form1"];
}

public class FormEntry {
private String mTextBox = "";

public String TextBox {
get {
return mTextBox;
}
set {
mTextBox = value
}
}

Then insert in your form2 HTML:
<%= Form1.TextBox %>



in article http://www.velocityreviews.com/forums/(E-Mail Removed), Paul Hale at
(E-Mail Removed) wrote on 10/28/03 12:41:

> Hi,
>
> I have two web forms (lets call them webform1 and webform2) that run
> as part of the same web application.
>
> Webform1 contains a text box. I would like to pop up a new browser
> window (containing webform2) and read the contents of the text box in
> webform1 and display in webform2.
>
> Is it possible to do this without posting the contents in a form or
> over http or setting up a cache.
>
> Ie - Something like declaring the text box public in webform1 and
> then...
>
> (Code in webform 2)
>
> dim objWebForm1 as webform1)
> response.write(objWebForm1.mytextbox.text)
>
> Hopefully you get what im trying to do!
>
> Thanks for any help!
>
> Paul.


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      10-28-2003
> Is it possible to do this without posting the contents in a form or
> over http or setting up a cache.


It is possible. It requires a number of things to be true. when a JavaScript
in an HTML document uses the window.open() method to open a new browser
instance, the function returns a handle to the window opened. This enables
the HTML documents in both windows to "talk to" each other. In the child
window, the parent window is accessible as "opener." In the parent window,
the child window is accessible as the handle created when opening the
window.

So, for example, if the first window has a textbox in it with the name "foo"
the child window can grab it's value thusly:

var s = opener.forms[0].foo.value;

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Paul Hale" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi,
>
> I have two web forms (lets call them webform1 and webform2) that run
> as part of the same web application.
>
> Webform1 contains a text box. I would like to pop up a new browser
> window (containing webform2) and read the contents of the text box in
> webform1 and display in webform2.
>
> Is it possible to do this without posting the contents in a form or
> over http or setting up a cache.
>
> Ie - Something like declaring the text box public in webform1 and
> then...
>
> (Code in webform 2)
>
> dim objWebForm1 as webform1)
> response.write(objWebForm1.mytextbox.text)
>
> Hopefully you get what im trying to do!
>
> Thanks for any help!
>
> Paul.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to add Web User Control to a Web Control Library? Brian Cryer ASP .Net 2 04-02-2008 09:19 AM
ASP.NET textbox loses text value in composite control but Textbox subclass doesn't!? ErwinP ASP .Net Web Controls 1 08-19-2005 01:50 PM
accessing the web user control's control from a web page and set a value from another web page Reny J Joseph Thuthikattu ASP .Net 1 12-30-2004 12:21 PM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM
Re: VERY STRANGE BUG? Adding a textbox control causes other textbox control to fail??? S. Justin Gengo ASP .Net 0 07-16-2003 06:51 PM



Advertisments