0

I have a page with 2 dropdrownlists & a submit button. I would like to pass the values(variables) of the dropdownlists to another page when I click submit.

Any thoughts or suggestions as to accomplish this. I have done something similar to this using asp:HyperLinkField, but I this does not work in my current scenario.

FluxEngine
  • 12,730
  • 14
  • 57
  • 83
  • A search for [asp.net values another page](http://stackoverflow.com/search?q=asp.net+values+another+page) gives you plenty of info to choose from. – Fredrik Mörk Apr 27 '11 at 13:08
  • possible duplicate of [How to transfer Form values from one asp.net page to other?](http://stackoverflow.com/questions/911129/how-to-transfer-form-values-from-one-asp-net-page-to-other) – Fredrik Mörk Apr 27 '11 at 13:08

3 Answers3

0

What about putting them in session and accessing them from session on another page?

Subhash Dike
  • 1,836
  • 1
  • 22
  • 37
0

You need to place a declaration on the second page where data come from.

So you have:

PostBackUrl="SecondPage.aspx"

On SecondPage.aspx you declare where you can get informations

<%@ PreviousPageType VirtualPath="~/FirstPage.aspx" %>

and you get them by...

if (Page.PreviousPage != null)
{
    if(Page.PreviousPage.IsCrossPagePostBack == true)
    {
        GetTheClass = PreviousPage.CustomDataClass;
        // or you find your control, and get your data
    }
}

Some reference.
Cross-Page Posting in ASP.NET Web Pages

ASP.NET how to access public properties?

Cross-page postbacks and back again retaining data from source page

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • this is what I have for the submit event... what else do I need to pass these two variables? Protected Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click PostBackUrl = "LiveEventCity.aspx?STATE={0}&CITY={1}" End Sub – FluxEngine Apr 27 '11 at 13:40
  • Good Idea :).. That's why I started my answer with "What about" as it was just another opinion that would work. Not sure what the asker is looking for anyway – Subhash Dike Apr 27 '11 at 13:41
  • @user630581 Yes of course you can pass it from url - this is not post (as you ask) however, is just a link, and you need ether to make it with javascript, ether to make it after the post. – Aristos Apr 27 '11 at 22:24
0

cant u use this:

PreviousPage.VAR1 = cboBox1.Text
PreviousPage.VAR2 = cboBox2.Text 

with PreviousPage being the name of your other page??

ProblemAnswerQue
  • 535
  • 1
  • 3
  • 18