Data transfering with few WebForms

P

Piotr Karwatka

Hi!

I have a little problem an qeustion.

In .NET Windows Forms I can do something like that:
- i have forms - Form1 Form2, on first form i have TextBox1 control on 2nd
form I have Button1 control
- on second Form i can acces data from Form1 like that:

for example: MessageBox.Show(Form1.TextBox1.Text);

That's simply and logical.

But Can i do something like that in WebForms?

I have problems with transfering data between to WebForms (2 *.aspx pages) -
i can't have acces to WebForm2.TextBox1 (example) from any method
implemented in WebForm1 - namespace is the same and that is not so logical
for me. That way of transferig data could be very easy to use and useful but
i don't know is that possible? And if is in what way?

Of course i can use Page.FORM collection but this is not so easy.

If you can write me how i would acces control from one page on the other i
will be very thankfull :)

I have programmed a lot in PHP, Java and asp.net is something totally new
for me.

ps. Sorry for not sa good english :)
 
K

Kevin Spencer

Hi Piotr,
- on second Form i can acces data from Form1 like that:

for example: MessageBox.Show(Form1.TextBox1.Text);

That's simply and logical.

Not as simple and logical as you think. The only way that one Windows Form
can "see" data in another Windows Form is if they are both memory-resident
in the same application at the same time. If they are 2 disconnected Windows
Forms executables, they must message each other via the OS or network.

A web application runs in HTTP context, which means that while the web
application memory is shared among all pages (WebForms), the pages
themselves don't co-exists in the same memory space at the same time. A
WebForm exists from the time an HTTP Request is received until the time that
the Response is sent. This means that WebForms must communicate in the same
way that separate Windows Form processes must communicate: via the server or
network.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
G

Guest

You probably want to look at something like server.transfer which will allow
you to pass information between webforms. alternatively look at the caching,
session, state options available in asp.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top