運用PreviousPage簡化提交流程

2022-03-24 02:03:22 字數 474 閱讀 1564

運用previouspage簡化提交流程

若是乙個page1.aspx向page2.aspx提交的流程,則在page2.aspx的頂部新增如下宣告:

<%@ previouspagetype virtualpath="~/page1.aspx" %>

設定page1.aspx的postbackurl屬性為~/page2.aspx。

假設page1.aspx的codebehind中有名為test()的方法,則在page2.aspx中可以這樣呼叫:

if (previouspage != null && previouspage.iscrosspagepostback)

順便記錄一下註冊客戶端指令碼的方法:

static readonly string script = "";

clientscript.registerstartupscript(script.gettype(), "error", script);

使用PreviousPage獲取源頁資訊

下面這個例子是演示在masterpage母板下面。例子始起頁放乙個textbox和乙個button,並用postbackurl來導向目標頁。如 asp content id content1 contentplaceholderid contentplaceholder1 runat server ...

使用PreviousPage獲取源頁資訊

下面這個例子是演示在masterpage母板下面。例子始起頁放乙個textbox和乙個button,並用postbackurl來導向目標頁。如 asp content id content1 contentplaceholderid contentplaceholder1 runat server ...

使用PreviousPage獲取源頁資訊 2

你可以參考這篇 insus.net覺得它寫得很不理想。因為不想寫得這樣複雜,或者有其它id變化的可能,如 contentplaceholderid contentplaceholder1 有可能變為contentplaceholderid contentplaceholder3 id textbox...