Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding bootstrap elements to asp textbox

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:TextBox ID="UserName" runat="server" Width="250px" TabIndex="1"></asp:TextBox>

And the input that I designed using html is:

<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?

like image 363
marchemike Avatar asked Mar 26 '26 05:03

marchemike


2 Answers

You can put these classes in asp textbox using CssClass as follows

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

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

There may be difference in the id and the name of the control. As they are generated depending on the controls like master page and user controls.

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

like image 66
शेखर Avatar answered Mar 28 '26 18:03

शेखर


<asp:TextBox ID="UserName" runat="server" CssClass="form-control input-lg" 
    Width="250px" TabIndex="1" placeholder="Username"></asp:TextBox>
like image 43
sakir Avatar answered Mar 28 '26 18:03

sakir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!