Get the App
SLTechnology News&Howtos  ›  Development  › 

How to POST the form to other pages in ASP.Net

Shulou Source: shulou.com Published: 2022-06-03 07:46:34 10月03日 Update

This article introduces the relevant knowledge of "how to implement the form POST to other pages in ASP.Net". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

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

The copy code is as follows:

Form1.action= "test.aspx"

Then it will result in the error of view validation error, because of the Asp.net security mechanism. We can also turn off this validation and add the header (test.aspx) to the acceptance page.

The copy code is as follows:

But this is not very safe. In fact, asp.net 2.0 also provides a way to submit to other pages. The server button control provides a property: PostBackUrl, which is written like this.

The copy code is as follows:

Button1.PostBackUrl= "test.aspx"

In this way, it will not cause the problem of validation errors, and it is safe.

-

By the way, there are some ways to dynamically modify form form properties, which have nothing to do with the above: for example, modify the target property

Normal page:

The copy code is as follows:

((System.Web.UI.HtmlControls.HtmlForm) this.FindControl ("form1")) .Target = "_ blank"

Or

The copy code is as follows:

Form1.Attributes ["target"] = "_ blank"

With master page master:

The copy code is as follows:

((System.Web.UI.HtmlControls.HtmlForm) this.Master.FindControl ("form1")) .Target = "_ blank"

Front desk modification:

The copy code is as follows:

Tags: Code pages forms security properties errors validation content methods more knowledge services practical ordinary successful learning next foreground dynamic dilemma head Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Xiaomi Redmi NVidia MySQL