Answered by:
Can't change textbox backcolor

Question
-
User832731860 posted
Hello All,
I'm building an app that is a basic daytimer type of app. My problem is that I can't get the textbox(Textbox1) backcolor and text to change when I need it to. For instance, if there are events for January 12 and the user clicks on the Jan 12 link in the Calendar control, if there are any events in the SQL table for that day it should populate the appropriate times. The funny, or not so funny, thing is that I have another textbox named "TheEvent" that I can change the backcolor and text on with the code below and it works fine.
I don't know if it matters or not,
So, I'm lost and need help. THANKS in advance!
Mike
Here's the Code:
Protected Sub Calendar4_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar4.DayRender Dim CountEvents Dim BegTime Dim TimeEnd Dim NumRec Dim Duration As TimeSpan NumRec = 1 'Label67.Text = "Enter Events Here For " & Calendar4.SelectedDate.ToLongDateString Label66.Text = Calendar4.SelectedDate.ToLongDateString MonthSelected.Text = "January" TheDay.Text = Calendar4.SelectedDate.Day CountEvents = GridView2.Rows.Count 'MsgBox(CountEvents) If NumRec <= CountEvents Then While Not NumRec > CountEvents If CountEvents = 1 Then BegTime = GridView2.Rows(0).Cells(3).Text TimeEnd = GridView2.Rows(0).Cells(4).Text Duration = Convert.ToDateTime(TimeEnd) - Convert.ToDateTime(BegTime) If BegTime = "8:00 am" Then Textbox1.BackColor = Color.Blue Textbox1.Text = "Hi" End If Else BegTime = GridView2.Rows(NumRec).Cells(3).Text TimeEnd = GridView2.Rows(NumRec).Cells(4).Text Duration = Convert.ToDateTime(TimeEnd) - Convert.ToDateTime(BegTime) End If NumRec = NumRec + 1 End While End If End Sub
<?xml:namespace prefix = mce /><mce:script type="mce-text/javascript"></mce:script>
Saturday, January 9, 2010 9:17 PM
Answers
-
User845932231 posted
Three things
1. make sure you are not doing anything for the TextBox1's text or background color in the page load outside Not IsPostback
2. Put a break point in the line If BegTime = "8:00 am" Then and see whether the code below is actually getting executed.
3. Make sure not any CSS styles are overriding the background color that you are applying to the textbox.. use Firebug to check this or run the code after removing any CssClass or Theme applied to the textbox.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, January 9, 2010 11:44 PM
All replies
-
User845932231 posted
Three things
1. make sure you are not doing anything for the TextBox1's text or background color in the page load outside Not IsPostback
2. Put a break point in the line If BegTime = "8:00 am" Then and see whether the code below is actually getting executed.
3. Make sure not any CSS styles are overriding the background color that you are applying to the textbox.. use Firebug to check this or run the code after removing any CssClass or Theme applied to the textbox.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, January 9, 2010 11:44 PM -
User832731860 posted
Thanks Anzer, but I realized that coding error was a simple oversight on my part. I didn't have the appropriate code in the DayRender sub. I appreciate the quick response though.
Mike
Monday, January 11, 2010 6:20 AM