Home > Backend Development > C#.Net Tutorial > How to POST form in asp.net to other pages

How to POST form in asp.net to other pages

伊谢尔伦
Release: 2016-11-25 09:12:57
Original
1525 people have browsed it

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:


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template