vb.net - How to clear backcolor & frontcolor change after changing color of textbox - Stack Overflow

admin2025-04-15  3

I am making a table to checking manual input video info. If input doc (xxx.xml) is not found, it will turn the text boxes background color red and front color white.

Problem

When user delete the incorrect input segment, it won't do input checking and the textbox will reset to white background color and black front color. However, the duration column did not clear the css changes and get a bug which another 2 textboxes turn red when mouse hover on them.

If I use Drawing.Color.Empty the duration will change front color to white and hidden the text. Does anyone know how to fix it?

Remark: only 1 use empty (XXX.BackColor = Drawing.Color.Empty , XXX.ForeColor = Drawing.Color.Black) is not work, both become empty.

CODE

Dim FileName As RadTextBox = CType(r.FindControl("txtFileName"), RadTextBox) 'mxf
Dim timeIn As RadTextBox = CType(r.FindControl("txtTimeIn"), RadTextBox)
Dim timeOut As RadTextBox = CType(r.FindControl("txtTimeOut"), RadTextBox)
Dim Duration As RadTextBox = CType(r.FindControl("txtDuration"), RadTextBox)

If FileName.Text <> "" Then
// Red bg warning for incorrect input

Else
  // Reset empty semgment textbox color
   FileName.BackColor = Drawing.Color.White
   FileName.ForeColor = Drawing.Color.Black

   timeIn.BackColor = Drawing.Color.White
   timeIn.ForeColor = Drawing.Color.Black

   timeOut.BackColor = Drawing.Color.White
   timeOut.ForeColor = Drawing.Color.Black

   Duration.BackColor = Drawing.Color.White
   Duration.ForeColor = Drawing.Color.Black
End If

I am making a table to checking manual input video info. If input doc (xxx.xml) is not found, it will turn the text boxes background color red and front color white.

Problem

When user delete the incorrect input segment, it won't do input checking and the textbox will reset to white background color and black front color. However, the duration column did not clear the css changes and get a bug which another 2 textboxes turn red when mouse hover on them.

If I use Drawing.Color.Empty the duration will change front color to white and hidden the text. Does anyone know how to fix it?

Remark: only 1 use empty (XXX.BackColor = Drawing.Color.Empty , XXX.ForeColor = Drawing.Color.Black) is not work, both become empty.

CODE

Dim FileName As RadTextBox = CType(r.FindControl("txtFileName"), RadTextBox) 'mxf
Dim timeIn As RadTextBox = CType(r.FindControl("txtTimeIn"), RadTextBox)
Dim timeOut As RadTextBox = CType(r.FindControl("txtTimeOut"), RadTextBox)
Dim Duration As RadTextBox = CType(r.FindControl("txtDuration"), RadTextBox)

If FileName.Text <> "" Then
// Red bg warning for incorrect input

Else
  // Reset empty semgment textbox color
   FileName.BackColor = Drawing.Color.White
   FileName.ForeColor = Drawing.Color.Black

   timeIn.BackColor = Drawing.Color.White
   timeIn.ForeColor = Drawing.Color.Black

   timeOut.BackColor = Drawing.Color.White
   timeOut.ForeColor = Drawing.Color.Black

   Duration.BackColor = Drawing.Color.White
   Duration.ForeColor = Drawing.Color.Black
End If
Share Improve this question edited Feb 4 at 9:35 Matthew asked Feb 4 at 9:03 MatthewMatthew 156 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Use

XXX.DisabledStyle.BackColor

XXX.HoveredStyle.BackColor

XXX.FocusedStyle.BackColor

instead of XXX.BackColor (ForeColor same method)

Ref:

  1. https://www.telerik.com/forums/radtextbox-changing-color-on-mouseover-for-no-reason
  2. https://www.telerik.com/products/aspnet-ajax/documentation/controls/textbox/appearance-and-styling/styles
转载请注明原文地址:http://www.anycun.com/QandA/1744731782a86834.html