頁面間傳值

來源:互聯網
上載者:User

標籤:style   blog   color   使用   os   io   strong   資料   

1.Session方法

   A.aspx傳參數,在點擊控制項函數中

protected void LinkButton1_Click1(object sender, EventArgs e){    String strId = txtCid.Text;    Session["C_Id"] = strId;//記錄C_ID    Server.Transfer("~/emp/Employee.aspx");}

  B.aspx接收參數

String vCId = Session["C_Id"].ToString();

 

2.地址欄傳值

 A.aspx按鈕函數中傳參數

protected void LinkButton1_Click1(object sender, EventArgs e){    String strId = txtCid.Text;    Response.Redirect("~/emp/Employee.aspx?C_Id=" + strId);}

  B.aspx接收參數  

String vCId = Request.QueryString["C_Id"].ToString();

兩種方法對比:方法1使用Server.Transfer傳值,地址欄不變,如果在地址欄添加數值,會報錯,而且,在之後有可能丟失傳遞的資料

       方法2,在地址欄輸入數值就能到相應的頁面,如:當然,前提是輸入的數值正確或者加入報錯處理

        

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.