Solved

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

Posted on 2004-08-18
8
227 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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