odiseh
odiseh

Reputation: 26547

asp.net validation: how to compare values of 2 controls on the form and using some functions like substring,

I have to compare 2 values which are the text property of 2 textbox controls on my .aspx form.

Using Compare validator does not enough for, I have to use some functions like substring.

As far as I know, the Compare validator does not allow to use substring.

Using Custom validator and handle it's serer-side "ServerValidate" event, as you know, It gives 2 arguments (source and args), how can I compare a text property of other control in this function?

If I can not, what is your solution?

Upvotes: 0

Views: 628

Answers (1)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

In the "ServerValidate" event, you can access the controls text property

if(txtbox1.Text!=textbox2.Text)

{

//you can return what you want here.....

}

Upvotes: 1

Related Questions