2

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?

2 Answers 2

8

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

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Can be added more attributes inside ASP tag, but must have the attribute="value" structure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.