Solved

basic question: passing values from one form to another in asp.net.

Posted on 2004-08-18
8
229 Views
Last Modified: 2010-04-07
i have 2 webforms. webform1.aspx and webform2.aspx

in webform1.aspx i have a text box and a submit button.when i enter the value in textbox,and submit,it should go to webform2.aspx.

in webform2.aspx,display the value from webform1,aspx


thanks for your reply,

regards
prav
0
Comment
Question by:praveen79
  • 5
  • 3
8 Comments
 
LVL 2

Author Comment

by:praveen79
ID: 11829248
Using Sessions how can i get the result?
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 50 total points
ID: 11829267
Hi,

you can use 2 scenarios:
1. create an OnClick event of the button and there write Session[Key] = TextBox.Text
this will create a key value pair in the session collection
in the webform2 you can add a label control and assign it's Text property to the Session[Key].ToString

2. is to use Server.Transfer and then in the webform2 you can write Request.Form[id of the text box]

Regards,
B..M
0
 
LVL 2

Author Comment

by:praveen79
ID: 11829348
in your firstcase,

thanks for your reply,

its working with response.redirect.

but how can i get the same result withOUT using  redirect method ?

thank you once again,


regards
prav



0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 2

Author Comment

by:praveen79
ID: 11829430
in my webform1.aspx,form tag is:

<form id="Form1" method="post" runat="server" action="WebForm2.aspx">

but still not working.

anything wrong in my form tag?

i am trying to get same result without using response.redirect method.


0
 
LVL 28

Expert Comment

by:mmarinov
ID: 11829457
No, you have not do this
remove action from the form tag
in .net it is not like the normal asp

to using something else than Response.Redirect use Server.Transfer
you have to write some code that will tell .net framework what to do

in the asp this was the action attribute, but NOT HERE

Server.Transfer("WebForm2.aspx")

Regards,
B..M
0
 
LVL 2

Author Comment

by:praveen79
ID: 11831109
Hi,

Thank you for your answer.


In real time (for example in Shopping Cart Application)
,normally for passing parameters from one form to another form,which technique can be used..using Sessions or Server.Transfer or some other technique?


I hope you can reply.. :)

regards,
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 11831257
actually, you can use both of them
using sessions is a little bit more complicated because you have to dispose every key pairs when you don't need them anymore
with server.transfer you don't have to worry about this because everything is there only when submitting the page

my suggestion is to create a class with properties that holds all the needed information: customername, ordered items, prices etc and then before moving from page to page add an object of this class to the session
then you will have less items in the session collection but everything will "travel" with the customer in every time

Regards
B..M
0
 
LVL 2

Author Comment

by:praveen79
ID: 11831732
Hi,

thankyou for your reply,

can you have a look at
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21098310.html

i think its better to solve this question with your idea.

(my suggestion is to create a class with properties that holds all the needed information: customername, ordered items, prices etc and then before moving from page to page add an object of this class to the session
then you will have less items in the session collection but everything will "travel" with the customer in every time).


am i  right?


regards
prav




but anyway i will try it.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question