我应该使用ASP:标签标签? [英] Should I use the ASP:Label tag?
问题描述
我要建一个形式ASP.NET来发送电子邮件。到目前为止,工作的事情伟大的,我能够给我的ASP传递:文本框内容的电子邮件没有任何问题。现在我是如何做的事情放在静态文本为TB标签,然后按照它与结核病控制输入。
I'm building a form in ASP.NET to send an email. So far things work great and I'm able to pass my ASP:TextBox contents to the email without any issue. Right now how I've done things is put in static text as the TB label and then follow it up with a TB control for the input.
我应该使用ASP:Label控件,而不是
Should I be using the ASP:Label control instead?
code例如:
<div>
Pub Contact Phone: <asp:TextBox ID="PublicationContactPhone" runat="server" TabIndex="9"></asp:TextBox>
</div>
有没有一种形式的最佳做法,说给所有的非输入文本作为标签,或者是preference?
Is there a form best practice that says to have all the non-input text as labels or is it preference?
推荐答案
这听起来像ASP.NET的可能是查询股价&LT; ASP:标签&gt;
控制和HTML &LT;标签&gt;
元素。对于建筑形态是使用HTML ℃的良好实践;标签&gt;
为输入标签,以便点击标签会给input元素焦点,可以实现标签两种方式:
This sounds like maybe a mixup of the ASP.NET <asp:Label>
control and the HTML <label>
element. For building forms it's a good practice to use the HTML <label>
for an input label so that clicking on the label will give the input element focus, you can implement a label two ways:
- 将静态文本和输入标签在一起(例如
&LT;标签&gt; A文本框&LT;输入ID =txtbox1类型=文本/&GT;&LT; /标签&gt;
) - 在标签处静态文本,并设置标签,以输入的
ID
在为
属性(例&LT;标签=txtbox1&gt;将文本框&LT; /标签&gt;&LT;输入ID =txtbox1类型=文本/&GT;
)
- place static text and input in the label together (ex.
<label>A TextBox <input id="txtbox1" type="text" /></label>
) - place static text in the label and set a
for
attribute on the label to theid
of the input (ex.<label for="txtbox1">A TextBox</label> <input id="txtbox1" type="text" />
)
所以,你可以标记您的页面像这样的文字酒吧联系电话:
可点击以聚焦输入
So you can markup your page like so and the text Pub Contact Phone:
will be clickable to give focus to the input
<div>
<label>
Pub Contact Phone:
<asp:TextBox ID="PublicationContactPhone" runat="server" TabIndex="9" />
</label>
</div>
这篇关于我应该使用ASP:标签标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!