473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.
Nov 17 '05 #1
2 910
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 2d**************************@posting.google.com, Paul Hale at
pa*******@safenames.co.uk 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.


Nov 17 '05 #2
> 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" <pa*******@safenames.co.uk> wrote in message
news:2d**************************@posting.google.c 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.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JayDee | last post by:
After a user enters data into a field, I need to populate other controls on the form, based on the user entry. I have to use either Leave, Validating or Validated, and I take it I can't use...
0
by: SpotsPlay | last post by:
If I bind a TextBox to a property on a "BusinessObject", the first time that TextBox is edited (each time the form/user control is opened) hitting Tab or clicking on another control on the...
2
by: Paul Hale | last post by:
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...
4
by: Rich | last post by:
Hello, I have 3 textboxes and 1 combobox on a form. On entering the control I want to select all the text. I can make an array of textboxes like this: Dim arrTxt As TextBox() = {txt1, txt2,...
2
by: clickon | last post by:
I have posted this question 3 times now and no-one has even answered it, so is it possibly a bug or am i missing something. In short it does not seem to be possible to set the focus on control...
10
by: aarepasky | last post by:
I am using ASP Web 2005 express. I created the user control below and I am listing the html code. I have 2 textboxes. One is txtCompanyName. The main page has 2 panels on it and a button. ...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
4
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have a strange yet very simple problem with the asp.net Textbox web control. On an empty asp.net page, add a single asp:TextBox control with Autopostback=false with nothing else on...
11
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.