开发者

Passing Variables to a new page, when clicking submit

开发者 https://www.devze.com 2023-03-01 05:01 出处:网络
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.

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 a开发者_如何学编程sp:HyperLinkField, but I this does not work in my current scenario.


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


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


cant u use this:

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

with PreviousPage being the name of your other page??

0

精彩评论

暂无评论...
验证码 换一张
取 消