Visual Studio Beginner with question

T

tripwater

Hello,
I am a php programmer moving over to ASP.NET, VS and C#. I am having a few
problems getting started. I have everything installed and running, it is
more or less figuring out how to do simple things.

I have a test form called webform1 with one field on it for a first name. I
am trying to figure out how to post this info to webform2 and display the
field value on webform2 in a label. In php and HTML all I had to do was put
webform2 in the action property of the form of webform1 and on post, access
the post var by $HTTP_POST_VARS["firstname"].

I figured out how to pass the value over to the other page via query string.
But if I had a form with 30 fields on it this would get tiresome. I just
need some guidance as to what I need to do to accomplish this simple task so
I can continue learning. I have been stuck on this for days and can not find
a tutorial online that goes beyond posting to the same page (i.e: webform1
posts info to webform1).

So I basically need to know how to pass a form's values to another page and
then access those variables on the next page(not the same page) within
Visual Studio (C#).


Thank you for any help in this.
 
M

Mark Rae

It works almost identically in ASP.NET.

Set the action of webform1 to point to webform2.
Within the <form></form> tags on webform1, create a text input field and
give it an ID of txtFirstName
Also create a submit button

Within the <form></form> tags on webform2, create an <asp:Label> field, give
it an ID of lblFirstName, and set its Runat property to "server"

In the code behind webform2 define a label variable:
protected Label lblFirstName;

In the Page_Load event of webform2, populate the Text property of
lblFirstName
lblFirstName.Text = Request.Form["txtFirstName"];
 

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

Top