Can't code RegularExpressionValidator correctly

R

Richard Lionheart

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
 
R

Richard Lionheart

Hi All,

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

Regards,
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top