Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validator Bug??? 1

Status
Not open for further replies.

vbkris

Programmer
Jan 20, 2003
5,994
IN
hi guys,

there seems to be a strange problem with validator controls. :(

steps to make it behave strangely (Code given below):
1. Enter a value in the first text box.
2. Move focus to second text box.
3. Delete the text in the first text box.
4. Use the MOUSE to give focus to the second text box.

Behavior that i got:
The validator control becomes editable! plus you can delete all content along with the textbox to validate!!!!!

What kind of behavior is this? do we have any MSDN support articles for the same???

Code for the testing:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>TestValidator</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5">[/URL]
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" cellSpacing="1"
				cellPadding="1" width="700" border="1">
				<TR>
					<TD><STRONG>Mandatory Validation</STRONG></TD>
					<TD></TD>
				</TR>
				<TR>
					<TD>Empty Label</TD>
					<TD>
						<asp:TextBox id="TextBox1" EmptyLabel="Enter the value!!" runat="server"></asp:TextBox>
						<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="<br>RequiredFieldValidator"
							ControlToValidate="TextBox1" Display="Dynamic"></asp:RequiredFieldValidator></TD>
				</TR>
				<TR>
					<TD>Empty Label</TD>
					<TD>
						<asp:TextBox id="TextBox2" EmptyLabel="Enter the value!!" runat="server"></asp:TextBox>
</TD>
				</TR>
			</TABLE>
		</form>
	</body>
</HTML>

Known is handfull, Unknown is worldfull
 
The problem I found is the <br> tag. Once I removed it, it worked correctly.

What I meant was that once I removed it, the validator was not editable when the validation failed.
 
yup,

but unfortunately i cant do that. normally where do you guys place your validator controls? below the control???

Known is handfull, Unknown is worldfull
 
It depends.. sometimes below or to the right.
but unfortunately i cant do that.
Why don't you set the error message in code, in the Page_Load event? Then maybe the <br> won't cause a problem.

 
>>Why don't you set the error message in code, in the Page_Load event?

sorry dont get you. all my validator controls are currently dynamically added controls only...

Known is handfull, Unknown is worldfull
 
I was going by the code you gave. So you are setting the error message to ="<br>RequiredFieldValidator" in code when you add it to the page..
 
yup,
thats what i am doing...

Known is handfull, Unknown is worldfull
 
jbenson001 said:
So you are setting the error message to ="<br>RequiredFieldValidator" in code when you add it to the page..
yup,
thats what i am doing...
Above, you say that you are setting the value in code, yet when I said:
ca8msm said:
You'll need to encode the tags then. Use &lt; and &gt; respectively.
you said:
vbkris said:
unfortunately i cant do that
So, I'm confused. If you are setting the value in code, why can't you encode the "br" tag when you set it?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
>>So, I'm confused. If you are setting the value in code, why can't you encode the "br" tag when you set it

ca8msm,

i could do that, but am not doing that as the normal <br> itself is working. the problem with <br> that jim is stating is happening due to a browser issue.

in the example that i had posted we have two textboxes, one below the other. since the validator control is dynamic when an invalid value is set in the first control it squeezes itself between the two text boxes (because of the <br> otherwise it would appear to the right side of the textbox).

this causes a strange issue in the browser making the validator control editable!

That is what jim was stating, he said that removing the <BR> could solve it (as the validator control will not squeeze itself now). that was why i asked him how he normally placed his validator control...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top