简体   繁体   中英

Html Validation error in Asp.Net form

I have an Asp.Net website which is throwing up a W3C validation error on the form element

<form method="post" action="" id="form">

I'm using the web forms routing option, so the home page is blank, as you see in the above example.

However, I'm getting a validation error, detailed below:

 Bad value for attribute action on element form: Must be non-empty.

As I have no control of this I wondered how its possible to work round the issue, if at all. I can't imagine that every Asp.Net site in the world is broken.

* UPDATE *

Guys you're missing the point. The error relates to the action attribute being blank, but this is being rendered this way because the page name is actually blank. Its blank because I'm using url routing.

只是尝试像这样使用“ form”标签

<form method="post" action="" runat="server" id="form">

If you use ASP.Net website, there should be a main form like the below

<asp:Form runat="server" id="form1">
</asp:Form>

This will be rendered HTML

<form id="aspnet_Form" action="pagename.aspx">
</form>

But your code looks like, you removed the asp.net form and created your own form with out action attribute.

To submit any form you need to specify valid action attribute value . But it is missing in your code. Please speciffy action="somepage.aspx"

<form method="post" action="your page" runat="server" id="form">

你可以清楚地从你的错误消息的答案的东西应该有在actionform

我只是在后面的代码中添加了以下内容:

this.Form.Action = "http://www.mywebsite.com/";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM