Solved

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

Posted on 2004-08-18
8
225 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now