close
http://itgroup.blueshop.com.tw/ianchen/design543?n=convew&i=3997
關於Page.PreviousPage主要用來實現
在ASP.NET裡由A頁傳值到B頁的用法
簡單說在Button的PostBackUrl設成B頁
然後在B頁裡用以下方式,就可以接到A頁傳來的值
1 | TextBox TextBox2 = Page.PreviousPage.FindControl("TextBox1") as TextBox; |
2 | Response.Write (TextBox2 .Text); |
開新視窗(view plain) | 列印(print) | ? |
但在講求整體設計裡,愈來愈多情況下會使用到具有Master Page的Layout設計
而當你有套用Master Page時,想由A頁傳值B頁就不能用上述的語法了,
你會發現你是Find不到A頁Control項的
而是必須先Find 到A頁裡的ContentPlaceHolder,再由ContentPlaceHolder去Find 你的Controlr囉
1 | ContentPlaceHolder ContentPlaceHolder1 = Page.PreviousPage.Master.FindControl ("ContentPlaceHolder1") as ContentPlaceHolder; |
2 | TextBox TextBox2 = ContentPlaceHolder1.FindControl("TextBox2 ") as TextBox ; |
3 | Response.Write (TextBox2 .Text); |
開新視窗(view plain) | 列印(print) | ? |
其實也不難理解,就想像ContentPlaceHolder是個容器,你想找到容器裡的東西,當然要先找到容器囉
全站熱搜
留言列表