asp.net mvc的htmlattribute没有价值 [英] asp.net mvc htmlattribute without value
问题描述
我想根据HTML5规范,其中没有一个值用于隐藏属性创建一个隐藏的表单。现在,我不知道如何迫使它进入asp.net MVC的
I am trying to create a hidden form according to the HTML5 spec, where the hidden attribute is used without a value. Now I have no idea how to force it into asp.net mvc's
<% Html.BeginForm("ChangeContent", "Content", FormMethod.Post, new {hidden}); %>
方法之一以上不编译
method as the one above does not compile with
Compiler Error Message: CS0103: The name 'hidden' does not exist in the current context
任何人知道出路?
Any one knows a way out?
修改
就使用默认的HTML辅助出于好奇?
Just out of curiosity using default html helpers?
推荐答案
我有一种感觉,你想要的默认 BeginForm
方法是不行的。您可以创建将输出&LT一个新的
标签,如你所愿,或只写在 BeginForm
方法;形式&GT; &LT;形式&GT;
标记 HTML
手动或使用路由引擎中的URL地址:
I have a feeling that the default BeginForm
method will not do what you want. You can either create a new BeginForm
method that will output the <form>
tag as you wish, or just write the <form>
tag manually in HTML
and fill in the URL using the routing engine:
<form action="<%: Url.Action("ChangeContent", "Content") %>" method="post" hidden>
...
</form>
更新:
要回答你的问题的编辑,使用标准的助手,这是不可能的。这里是MSDN上的参考: http://msdn.microsoft.com/en-美国/库/ dd492714.aspx 。根据该文件,属性必须是名称/值对。
To answer your question edit, this is not possible using the standard helpers. Here is the reference on MSDN: http://msdn.microsoft.com/en-us/library/dd492714.aspx. According to the documentation, the attributes must be name/value pairs.
这篇关于asp.net mvc的htmlattribute没有价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!