[英]Prevent self closing html tags in ASP.NET Web Forms
I'm learning ASP.NET Web Forms and I'm wondering if it's possible to prevent self closing tags when the html code is generated. 我正在学习ASP.NET Web窗体,并且想知道在生成html代码时是否有可能防止自闭标签。 For instance, if I create an input element, it will self close.
例如,如果我创建一个输入元素,它将自动关闭。 How can I prevent this?
我该如何预防?
Here is the code I'm referring to: 这是我指的代码:
<asp:TextBox id="txt1" runat="server"></asp:TextBox>
Thank you! 谢谢!
Edit: I recently installed Visual Studio 2013 Ultimate and this is what I found: 编辑:我最近安装了Visual Studio 2013 Ultimate,这是我发现的内容:
And then: 接着:
However, <asp:TextBox runat="server"></asp:TextBox>
still gives me <input type="text" />
in the compiled HTML5 code. 但是,
<asp:TextBox runat="server"></asp:TextBox>
<input type="text" />
在已编译的HTML5代码中仍为我提供<input type="text" />
。 The result I want is <input type="text">
. 我想要的结果是
<input type="text">
。
So if anyone knows how to accomplish this, I would appreciate it. 因此,如果有人知道如何实现这一目标,我将不胜感激。 Thanks!
谢谢!
If you are using Visual Studio 2010, you can go to : 如果您使用的是Visual Studio 2010,则可以转到:
Tools > Options > Text Editor > HTML > Formatting > Tag Specific Options 工具>选项>文本编辑器> HTML>格式>标记特定选项
In here you can change the Default Setting of Client and Server tags to be Seperate
/ Self-Closing
. 在这里,您可以将“客户端和服务器”标签的“默认设置”更改为“
Seperate
/ Self-Closing
。
You can also change it for specific elements, ie <img>
tags by Finding the img
item under Client HTML Tags
您还可以通过在“
Client HTML Tags
下找到img
项目来更改特定元素(即<img>
标记)的值
If you are using Visual Studio 2015, you can go to : 如果您使用的是Visual Studio 2015,则可以转到:
Tools > Options > Text Editor > HTML > Advanced > XHTML Coding Style - False 工具>选项>文本编辑器> HTML>高级> XHTML编码样式-False
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.