Home  >  Article  >  Backend Development  >  How to POST form in asp.net to other pages

How to POST form in asp.net to other pages

伊谢尔伦
伊谢尔伦Original
2016-11-25 09:12:571522browse

In ASP, we usually submit the form to another page (accepting data page). But in ASP.NET, server-side forms are usually submitted to this page. If I set

form1.action="test.aspx";

, it will cause a view validation error, because Asp.net caused by safety mechanisms. We can also turn off this verification and add

in the header of the acceptance page (test.aspx) <%@ Page EnableViewStateMac="false" %>

But this is not very safe. In fact, asp.net 2.0 is still Provides a way to submit to other pages. The server button control provides an attribute: PostBackUrl. Write like this

button1.PostBackUrl="test.aspx";

This will not cause verification errors and is very safe. .

------------------------------------------------ ----------------------------------------

By the way, here is a way to dynamically modify form attributes. Some methods have nothing to do with the above: For example, modify the target attribute

Normal page:

((System.Web.UI.HtmlControls.HtmlForm)this.FindControl("form1")).Target = "_blank";

Or

form1.Attributes["target"] = "_blank";

including master page master:

((System.Web.UI.HtmlControls.HtmlForm)this.Master.FindControl("form1")). Target = "_blank";

Front-end modification:


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn