473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Setting button color not being rendered

I want to be able to change the color of the text of a button after it is
pressed.

The first part of the event is:

sub submitQuestion_click(Sender as Object, e as EventArgs)
trace.warn("Sender text = " & Sender.text)
trace.warn("Sender color = " & Sender.ForeColor.ToString())
Sender.ForeColor = System.Drawing.Color.Red

I am doing the trace.warns to make sure I have the correct button. And to
make sure the color was changed ( and is being preserved as the page is
posted back) - which it is.

The trace shows:

Sender text = Select 0.004294 0.000098
Sender color = Color [Red] 0.004396 0.000102

(it shows Color [Empty] the first time through as it should).

But the buttons text does not show as read. From viewsource it shows as:

<input type="submit" name="DataList1:_ctl3:submitQuestion" value="Select"
id="DataList1__ctl3_submitQuestion" />

As you can see, there is no red being rendered?

How do I do this?

Thanks,

Tom
Nov 19 '05 #1
1 1473
"tshad" <ts**********@ftsolutions.com> wrote in message
news:OP**************@TK2MSFTNGP12.phx.gbl...
I want to be able to change the color of the text of a button after it is
pressed.

The first part of the event is:

sub submitQuestion_click(Sender as Object, e as EventArgs)
trace.warn("Sender text = " & Sender.text)
trace.warn("Sender color = " & Sender.ForeColor.ToString())
Sender.ForeColor = System.Drawing.Color.Red

I am doing the trace.warns to make sure I have the correct button. And to
make sure the color was changed ( and is being preserved as the page is
posted back) - which it is.

The trace shows:

Sender text = Select 0.004294 0.000098
Sender color = Color [Red] 0.004396 0.000102

(it shows Color [Empty] the first time through as it should).

But the buttons text does not show as read. From viewsource it shows as:

<input type="submit" name="DataList1:_ctl3:submitQuestion" value="Select"
id="DataList1__ctl3_submitQuestion" />

As you can see, there is no red being rendered?

How do I do this?
MS docs say that Forecolor is supposed to set the text color of the button

I also tried:

Dim submitButton as Button = CType(sender,button)
submitButton.Style = "color:red"

But get an error that "style" is read only.

For a test, I tried to set "forecolor=red" on the object itself:

<asp:button ID="submitQuestion" ForeColor="red" CommandName="SubmitQuestion"
runat="server" Text="Select" OnClick="submitQuestion_click" />

And it never renders the red.

If I put the style on the object:

<asp:button ID="submitQuestion" style="color:red"
CommandName="SubmitQuestion" runat="server" Text="Select"
OnClick="submitQuestion_click" />

It renders fine and the color of the text is shown correctly.

In one case, it doesn't work at all (even though MS says it will), in the
other case (which works initially) - you can't change it.

How do I get around this?

Tom
Thanks,

Tom

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: George Durzi | last post by:
I'm trying to set focus on an asp:textbox. I'm running this code after my page_load StringBuilder sb = new StringBuilder(); sb.Append(@"<script language=javascript>"); sb.Append(@"<!--");...
10
by: Steve | last post by:
Hi- I had this nice little wizard application running. It was comprised of several Panel controls initially set w/ their visibility off except for the first one, then as you progress through...
6
by: Angel | last post by:
I have a button, combo, and custom control that i created. When I click the button i want to set certain display properties of my custom control depending whats in the combo. I set those properties...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.