Solved

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

Posted on 2004-08-18
8
224 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
Comment Utility
Using Sessions how can i get the result?
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 28

Expert Comment

by:mmarinov
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

8 Experts available now in Live!

Get 1:1 Help Now