• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • ASP.NET 2.0 中實現跨頁提交

    發表于:2007-06-30來源:作者:點擊數: 標簽:
    在ASP.NET 1.x的時候,很多朋友可能需要進行跨頁提交的處理,也就是從頁面A能夠提交到頁面B,甚至不同的Control其目標處理頁面也各不相同。尤其是從ASP/JSP/ PHP 轉過來的 開發 人員,可能更有這種 需求 。但很不幸,在ASP.NET 1.x的時候,處理這種跨頁請求
         在ASP.NET 1.x的時候,很多朋友可能需要進行跨頁提交的處理,也就是從頁面A能夠提交到頁面B,甚至不同的Control其目標處理頁面也各不相同。尤其是從ASP/JSP/PHP轉過來的開發人員,可能更有這種需求。但很不幸,在ASP.NET 1.x的時候,處理這種跨頁請求是十分丑陋的,需要非常多的“技巧化”處理。
      
        在ASP.NET 2.0的時候,對于跨頁提交已經有了非常合理的解決方案,以下就是一個示例。
      
        SourcePage.aspx: 請注意Button1的PostBackUrl屬性設置
      
      <%...@ Page Language="C#" %>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <script runat="server">...
       public string YourName
       ...{
       get
       ...{
       return this.TextBox1.Text;
       }
       }
      </script>
      
      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
       <title>Untitled Page</title>
      </head>
      <body>
       <form id="form1" runat="server">
       <div>
       <asp:Label ID="Label1" runat="server" Text="請輸入您的姓名" Width="183px"></asp:Label>
       <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
       <asp:Button ID="Button1" runat="server" Text="提交" PostBackUrl="~/TargetPage.aspx" /></div>
       </form>
      </body>
      </html>
      
        TargetPage.aspx:請注意PreviousPageType的屬性設置
      
      <%...@ Page Language="C#" %>
      <%...@ PreviousPageType VirtualPath="~/SourcePage.aspx" %>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <script runat="server">...
      
       protected void Page_Load(object sender, EventArgs e)
       ...{
       this.Label1.Text = PreviousPage.YourName;
       }
      </script>
      
      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
       <title>Untitled Page</title>
      </head>
      <body>
       <form id="form1" runat="server">
       <div>
       <asp:Label ID="Label1" runat="server" ></asp:Label>
      
       </div>
       </form>
      </body>
      </html>
        OK,就通過這么簡單的兩個屬性設置,就可以非常方便的得到跨頁提交的特性。當然,您也可以根據您自己的需求,比如每個Control需要提交到不同的頁面來進行更加復雜的設置。
      
      
      

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>