单击提交时,将变量传递到新页面 [英] Passing Variables to a new page, when clicking submit

查看:153
本文介绍了单击提交时,将变量传递到新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,有2个dropdrownlists&提交按钮。当我点击提交时,我想将下拉列表的值(变量)传递给另一个页面。



完成此任务的任何想法或建议。我使用asp:HyperLinkField做了类似的工作,但是我在目前的情况下不起作用。

解决方案

你需要在第二页上发出数据来源的声明。



所以你有:

  PostBackUrl =SecondPage.aspx

在SecondPage.aspx上,您声明在哪里可以获取信息

 <%@ PreviousPageType VirtualPath =〜/ FirstPage.aspx%> 

,您可以通过...获取...

  if(Page.PreviousPage!= null)
{
if(Page.PreviousPage.IsCrossPagePostBack == true)
{
GetTheClass = PreviousPage.CustomDataClass;
//或者你找到你的控件,并获得你的数据
}
}

一些参考。

交叉页在ASP.NET网页中发布



ASP.NET如何访问公共属性



跨页面回发并再次保留来自源页面的数据


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.

解决方案

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

这篇关于单击提交时,将变量传递到新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆