最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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/forums/radtextbox-changing-color-on-mouseover-for-no-reason
  2. https://www.telerik/products/aspnet-ajax/documentation/controls/textbox/appearance-and-styling/styles
发布评论

评论列表(0)

  1. 暂无评论