Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting colors for Design Time Controls at run-time

Status
Not open for further replies.

computergeek

Programmer
May 23, 2001
193
CA
Hello,

How do you set the color for a textbox or label DESIGN TIME CONTROL at run-time within a script? There doesn't seem to be any properties to set at run-time within a script. In my code I change the text within the control based on some validation, then I want to set the text to green or red based on the validation.

Help please...

Thanks in advance your help!
 
CLIENT SIDE...
If you want to change the colors (colours) on the client-side (i.e. by using browser commands), then you will have to refer to the text box using client side javascript

document.thisPage.txtTextBox.style...

(refer to DOM documentation to figure-out how to change color etc.).

1. Labels are slighly harder, because they are not 'named' - so trying to find them in Client-Side code is tricky.
2. You will need to figure out which event causes your javascript to run. The usual DTC way is to add a thisPage_onbeforeserverevent event handler (search in help for this - and manually add the parameters).

SERVER SIDE...
If you want to do the colouring on the Server, then you can look at the _scriptlibrary files (LABEL.ASP & TEXTBOX.ASP). Currently, there are no features to apply colouring to labels or textboxes - but you could add properties to both to:
set a color and other font attributes
or
set a stylesheet id reference name (and create a stylesheet with appropriate id names).

I think that I have placed an example in the FAQ section of tek-tips, so check there.

NOTE: If you look at the HTML that is produced by DTC's you may find that you can add the font attributes on either side of each DTC.
ie

<% if nAmount > 100 then Response.Write &quot;<FONT COLOR=RED>&quot; %>
...your DTC goes here...
<% if nAmount > 100 then Response.write &quot;</FONT>&quot; %>
(Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top