码迷,mamicode.com
首页 > Web开发 > 详细

How to: Pass Values Between ASP.NET Web Pages

时间:2015-05-29 15:21:16      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

1. Use a query string, which appends information onto the URL of the target page. You can use a query string when using a HyperLink control to build navigation into a page or when you are programmatically redirecting to another page using the Redirect method.

2.Use session state to store information that is then accessible to all ASP.NET Web pages in the current application. However, this takes server memory, and the information is stored until the session expires, which can be more overhead than you want for simply passing information to the next page. For details, see ASP.NET State Management Overview.

3.On the target page, read control values and public property values directly out of the source page. This strategy works in two situations: when the source page cross-posts to the target page (for more information, see How to: Post ASP.NET Web Pages to a Different Page), and when you call the Transfer method to transfer execution from the source to the target page on the server. The strategy of reading values directly from the source page is described in this topic.

public String CurrentCity
{
    get
    {
        return textCity.Text;
    }
}
<%@ PreviousPageType VirtualPath="~/SourcePage.aspx" %> 
Label1.Text = PreviousPage.CurrentCity


-------------------------------------------------------------------
if (Page.PreviousPage != null)
{
    TextBox SourceTextBox = 
        (TextBox)Page.PreviousPage.FindControl("TextBox1");
    if (SourceTextBox != null)
    {
        Label1.Text = SourceTextBox.Text;
    }
}

4. cookie

5. web cache

6.

 

How to: Pass Values Between ASP.NET Web Pages

标签:

原文地址:http://www.cnblogs.com/Jenny90/p/4538288.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!