I have 2 webforms the closeporject button in webform 1 redirects to Webform 2 and asks whether do you really want to close the project. How can I capture the button click event of webform 2 in webform 1 ? Someone told me it has to do something with querystring in address bar. I am not allowed to use javascript to display my message box.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can post data from one page to the other. Here from Page2.aspx to Page1.aspx as
On the page2, you set PostBackUrl on the button that say Continue/Select what ever.
PostBackUrl="Page1.aspx"
and on Page1.aspx you set where can read the posted data.
<%@ PreviousPageType VirtualPath="~/Page2.aspx" %>
and you get the data as
if (Page.PreviousPage != null)
{
if(Page.PreviousPage.IsCrossPagePostBack == true)
{
// here you can get from Page2.aspx==PreviousPage
// a check box check, what ever you like...
GetTheClass = PreviousPage.MyDataClass;
}
}
relative: Cross-page posting. Is it a good pratice to use PreviousPage in Asp.net?
More about Cross Page posting: http://msdn.microsoft.com/en-us/library/ms178139.aspx