Asp.net多頁面間保留狀態

來源:互聯網
上載者:User
前言
今天是,我新工作的第二天,終於回到Csdn上,在自己的Blog上寫上第一篇文章。
不記得自己有幾個Blog了,今天開始決定,在這裡記錄下,我以後的日子與生活吧。
Asp.net多頁面間保留狀態
只記得Asp.net頁面內的狀態是由Viewstate來儲存的。我想頁面間是不是也可以借用Viewstate。
微軟說,Viewstate只是相對於單頁面來說的,並且,我還發現了,有好多的工作可以反編輯
頁面內的Viewstate。因為它是用Base64編碼的。當然也可以對它加密。既然,它不能滿足多頁面
間保留狀態問題,那就不用它了。
用Session是不是能解決呢:
我簡單試了一下,因為頁面的控制項還不是太多,剛好10個,我羅列了他們的Session值。然後在
Page_Load裡初始化它的狀態。如下:這樣就可以了。
private void Page_Load(object sender, System.EventArgs e)
{

if (!IsPostBack)
{
//
if (Session["deal_page"]!=null)
{//這裡是從其它頁傳過來的
if (Session["deal_page"].Equals ("deal_page"))
{
init_Form();
}
}

Bind_DragGrid();
}
}
private void init_Form()
{

txtCompanyname.Text = Session["seComp"].ToString();
txtRsrvman.Text = Session["seRsrv"].ToString();
txtPhone.Text = Session["sePhon"].ToString();
txtSaleManger.Text = Session["seSale"].ToString();
txtCRONum.Text = Session["seCron"].ToString();
txtGrpgstname.Text = Session["seGrpg"].ToString();
txtSdate.Text = Session["seSdate"].ToString();
txtEdate.Text = Session["seEdate"].ToString();
txtDptSdate.Text = Session["seDpts"].ToString();
txtDptEdate.Text = Session["seDpte"].ToString();

}
也許有更好的方法,但是我還沒有想太好。暫時先這樣用吧。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.