PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Can't code RegularExpressionValidator correctly

Reply

Can't code RegularExpressionValidator correctly

 
Thread Tools Rate Thread
Old 20-10-2005, 03:00 AM   #1
Richard Lionheart
Guest
 
Posts: n/a
Default Can't code RegularExpressionValidator correctly


Hi All,

I coding a simple web form that generates
- a couple of operand textboxes,
- a dropdown list of operations
- a "results" textbox
- an "error msg" label

The following code validates the operations list correctly.
However, it doesn't output any message when the first operand is blank.
What do I need to do to get the operand validation to output to lblMessage
when operand #1 is blank.
Should I just copy and paste the corrected code to perform the same check on
operand #2?

==============
private void btnEquals_Click(object sender, System.EventArgs e)
{
RegularExpressionValidator rev = new RegularExpressionValidator();
rev.ControlToValidate="tbOperand1";
rev.ValidationExpression="^\\d+$";
rev.ErrorMessage="The operands must contain only digits and at least one";
rev.Visible=true;
rev.Validate("tbOperand1");

if (cbOperation.SelectedItem.Text == "?")
{
lbMessage.Text = "Please select an operation in place of \"?\"";
return;
}
}
==============

Regards,
Richard


  Reply With Quote
Old 20-10-2005, 06:15 PM   #2
Richard Lionheart
Guest
 
Posts: n/a
Default Re: Can't code RegularExpressionValidator correctly

Hi All,

I found what I needed: a ValidationSummary tag. Found it in Prosise's
"Programming Microsoft .NET"

Regards,
Richard



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off