Actually, I have everything working at this point with the code below, accept whent the focus is set back on the control, if the user does not make any changes to the text box it is not checked again.....
Protected Sub itemPlotSummaryTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tb As TextBox = DirectCast(FormView1.FindControl("itemPlotSummaryTextBox"), TextBox)
Dim tooLong As Integer
tooLong = tb.Text.Length
If tooLong > 100 Then
MsgBox("The Plot Summary is too Long. The field is liimited to 100 characters, the field is currently " & tooLong & " characters in length.")
End If
SetFocus(FormView1.FindControl("itemPlotSummaryTextBox"))
End Sub
I guess the validator is the better option, I try and convert to that in VB though.
I am a bit miffed on the validator though. I'll post my progress shortly.
march11
Contributor
3017 Points
1367 Posts
Re: how can I check the number of characters entered into textbox prior to DB update?
Nov 10, 2010 01:51 PM|LINK
Actually, I have everything working at this point with the code below, accept whent the focus is set back on the control, if the user does not make any changes to the text box it is not checked again.....
Protected Sub itemPlotSummaryTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim tb As TextBox = DirectCast(FormView1.FindControl("itemPlotSummaryTextBox"), TextBox) Dim tooLong As Integer tooLong = tb.Text.Length If tooLong > 100 Then MsgBox("The Plot Summary is too Long. The field is liimited to 100 characters, the field is currently " & tooLong & " characters in length.") End If SetFocus(FormView1.FindControl("itemPlotSummaryTextBox")) End SubI guess the validator is the better option, I try and convert to that in VB though.
I am a bit miffed on the validator though. I'll post my progress shortly.