Html 将引导程序元素添加到 asp 文本框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24112965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:59:59  来源:igfitidea点击:

Adding bootstrap elements to asp textbox

htmlasp.nettwitter-bootstraptextbox

提问by marchemike

I'm fairly new in asp.net, and I am more proficient at building html/php websites.I am trying to add twitter bootstrap to my textboxes. My current textbox shows:

我在 asp.net 中相当新,而且我更擅长构建 html/php 网站。我正在尝试将 twitter bootstrap 添加到我的文本框。我当前的文本框显示:

<asp:TextBox ID="UserName" runat="server" Width="250px" TabIndex="1"></asp:TextBox>

And the input that I designed using html is:

我使用 html 设计的输入是:

<input type="text" class="form-control input-lg" placeholder="Username">

How do I put all the classes of my textbox to my asp textbox, and would it take effect in a similar way html elements work?

如何将我的文本框的所有类放入我的 asp 文本框,它是否会以类似的 html 元素工作方式生效?

回答by ????

You can put these classes in asp textboxusing CssClassas follows

您可以按如下方式asp textbox使用这些类CssClass

<asp:TextBox ID="UserName" runat="server" CssClass="form-control input-lg" 
    Width="250px" TabIndex="1"></asp:TextBox>

Basically when you create a control asp controlit render as a html control on the browser.
So in the browser you will see the same.

基本上,当您创建控件时,asp control它会在浏览器上呈现为 html 控件。
所以在浏览器中你会看到相同的内容。

There may be difference in the idand the nameof the control. As they are generated depending on the controls like master pageand user controls.

控件的id和可能存在差异name。因为它们取决于像控件生成master pageuser controls

Though you have different ClientIdModein asp.net to overcome this issue.
MSDN for the same is http://msdn.microsoft.com/en-us/library/system.web.ui.clientidmode.aspx

尽管您ClientIdMode在 asp.net 中有不同的方法来克服这个问题。
相同的 MSDN 是http://msdn.microsoft.com/en-us/library/system.web.ui.clientidmode.aspx

回答by sakir

<asp:TextBox ID="UserName" runat="server" CssClass="form-control input-lg" 
    Width="250px" TabIndex="1" placeholder="Username"></asp:TextBox>