1

I hope this isn't too difficult, obviously you can call HTML tags such as fieldset, label and legends and also textboxes. However how does one call an asp:textbox, i have tried just textbox, asp:textbox, input.textbox but nothing seems to work. This is something that should be really straight forward to do and I can't waste any more time figuring it out.

Thanks.

6 Answers 6

3

You can try input[type=text] but that will not work in IE6. Or you can create a class like .asp-textbox and set the CSSClass property of the textbox to asp-textbox which will work across browsers.

Example:

<asp:TextBox ID="TextBox1" runat="server" CssClass="asp-textbox"></asp:TextBox>

/*CSS*/
.asp-textbox{background-color:red;}
Sign up to request clarification or add additional context in comments.

1 Comment

Hello, thanks I see and understand exactly what you did there.
3

Understand that all of the ASP processing is done on the server, before anything gets to the user. When the user's browser is applying stylesheets, it doesn't see any of your ASP code — all it has is the HTML that's been generated by your ASP code.

So what you're trying to find out is what HTML is generated by the textbox tag. The answer is: it depends on the way the textbox is defined. If the TextMode attribute is set to "multiline", then it's rendered in HTML as a textarea element. If it's set to "password", then it's rendered as an input element of type "password". Otherwise, it's an input element of type "text".

Your best bet is probably to assign a class to your textboxes and reference that in your stylesheet.

Comments

1

it's an input (of type text)

it renders as <input type="text" />

Comments

1

The only cross browser way is to add a class to the textbox using CSSClass property and style that using the class. Also you can use the id selector. When using the id selector check for naming container also.

.test { }

<asp:textbox id="txt1" CssClass="test" runat="server" />

Comments

1

Try the following:

.myclass td.col1 input
{
   background-color: #D1FFC1;
}

This should work in IE also.

Comments

0

If I've understood you correctly, change the word "call" to "select", it's what CSS does (selects and element for styling). Use the property CssClass on the asp:Text in order to make it easily available to your CSS. Example:

.myClass { color: red; }

Comments

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.