I want to change the forecolor of an html text box at the code behind where its runat ="server" property set to true.

Posted on 2006-04-10
Last Modified: 2008-01-09
I want to change the forecolor of an html text box at the code behind where its runat ="server" property set to true.
How to do that?

any help is appreciated.

Question by:chaleastale
    LVL 5

    Accepted Solution

    I don't use such kind of technologies, but you could try to set its style this way: style="color:#ff0000; background-color:#000040"  (quotes included) and so on.

    LVL 2

    Expert Comment

    here is example in VB.Net to do it in code-behind: myTextBox.Style.Add("background-color", "red")
    in C# it is the same.

    Author Comment

    I couldn't find Style.Add on c# it is Attributes.Add. What about to change the forecolor?
    LVL 2

    Expert Comment

    Here is code in C#:
    TextBox1.Style.Add("color","red"); - text in textbox (forecolor) will have such color
    TextBox1.Style.Add("background-color","green");  - background of textbox will have such color
    LVL 2

    Expert Comment

    don't forget to put it into cs:
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    When pages do not download correctly, and you don't know why, the first thing you do is to look at the HTML source code of that page, but not all the downloaded files appear always clearly. If your source includes a javascript that computes the name…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now