Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

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

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
praveen79
Asked:
praveen79
  • 5
  • 3
1 Solution
 
praveen79Author Commented:
Using Sessions how can i get the result?
0
 
mmarinovCommented:
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
 
praveen79Author Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
praveen79Author Commented:
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
 
mmarinovCommented:
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
 
praveen79Author Commented:
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
 
mmarinovCommented:
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
 
praveen79Author Commented:
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now