我应该使用ASP:标签标签? [英] Should I use the ASP:Label tag?

查看:127
本文介绍了我应该使用ASP:标签标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个形式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:

  1. 将静态文本和输入标签在一起(例如&LT;标签&gt; A文本框&LT;输入ID =txtbox1类型=文本/&GT;&LT; /标签&gt;
  2. 在标签处静态文本,并设置标签,以输入的 ID 属性(例&LT;标签=txtbox1&gt;将文本框&LT; /标签&gt;&LT;输入ID =txtbox1类型=文本/&GT;
  1. place static text and input in the label together (ex. <label>A TextBox <input id="txtbox1" type="text" /></label>)
  2. place static text in the label and set a for attribute on the label to the id 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屋!

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