Cross-page posting. Is it a good pratice to use PreviousPage in Asp.net?

前端 未结 1 1315
暗喜
暗喜 2020-12-02 02:42

I found this article on MSDN talking about Cross-page posting.

I never worked with Page.PreviousPage. But I think its interesting.

Do you use it? Is it a g

1条回答
  •  自闭症患者
    2020-12-02 03:05

    The cross page posting is a helper to post some data to a different page and still have the asp.net code behind functionality.

    Why is this exist ? because asp.net have a limitation of one and only form per page. But actually to an html page you can have many forms and many different post to different pages.

    So to give a tool to that case, is let you set a second page to post the data, and you setup this on the Button (and not by placing second form), and from there is solve this issue, to post the data to a different page.

    For example... with out asp.net and with simple html on a page you can do that.

    
    
    Username:
    email for news letter:

    To solve a situation like this, and because asp.net not allow two forms at the same page, gives this option.

    
    
    Username: email for news letter:

    In the second case, you have one form, but you set the PostBackUrl to a different page, and from there asp.net still handle the data on code behind direct on a second page (with out redirect).

    I hope this example gives you and an idea where to really use the previous page. Also what is more usually is the Redirect, how ever there are case that you need to have the result to a different page. So its per case if you use it or not.

    0 讨论(0)
提交回复
热议问题