user2872841
user2872841

Reputation: 101

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. 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:

And then:

However, <asp:TextBox runat="server"></asp:TextBox> still gives me <input type="text" /> in the compiled HTML5 code. The result I want is <input type="text">.

So if anyone knows how to accomplish this, I would appreciate it. Thanks!

Upvotes: 2

Views: 1898

Answers (3)

coliff
coliff

Reputation: 1017

If you are using Visual Studio 2015, you can go to :

Tools > Options > Text Editor > HTML > Advanced > XHTML Coding Style - False

Upvotes: 0

Nick K
Nick K

Reputation: 389

Follow this link. Surely want you need is to

  1. Tools
  2. Options
  3. Text Editor
  4. HTML
  5. Formatting
  6. Uncheck the box for Auto insert close tag

Upvotes: 1

Nunners
Nunners

Reputation: 3047

If you are using Visual Studio 2010, you can go to :

Tools > Options > Text Editor > HTML > Formatting > Tag Specific Options

In here you can change the Default Setting of Client and Server tags to be Seperate / Self-Closing.

You can also change it for specific elements, i.e. <img> tags by Finding the img item under Client HTML Tags

Upvotes: 0

Related Questions