ASP.NET - 使用显式结束标记与否? [英] ASP.NET - using explicit end tags or not?

查看:311
本文介绍了ASP.NET - 使用显式结束标记与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:TextBox runat="server"   .... />

<asp:TextBox runat="server" .... ></asp:TextBox>

有没有使用一个比其他任何陷阱?

Are there any gotchas using one over the other?

推荐答案

我有一个例外@安德鲁的规则:
我在一个ASP.Net的形式被使用GridView和绑定一个记录它动态地进行调试(我并没有为它指定一个,但什么ID)。结果
当你拖动GridView控件到窗体,它创建了一个&LT; ASP:GridView的&GT;&LT; / ASP:GridView的&GT; code。我发现,如果我把关闭标签,关闭揭幕战/>时,GridView不会被显示出来。

在同样的注意,检查<一href=\"http://stackoverflow.com/questions/1162420/document-getelementbyid-fails-for-single-tag-div\">my上周,那里的人正确地评论说,HTML / XHTML,一些标记(如DIV)必须有关闭标签的问题。

I have an exception to @Andrew's rule: I've been using GridView in an ASP.Net form and binding a recordset to it dynamically for debug purposes (I didn't specify anything for it but an ID).
When you drag the GridView to your form, it creates an <asp:GridView></asp:GridView> code. I found out that if I drop the closing tag and close the opener with />, the GridView does not get displayed.

On the same note, check my question from last week, where people correctly commented that in HTML/XHTML, some tags (like DIV) must have a closing tag.

这篇关于ASP.NET - 使用显式结束标记与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆