Can we validate a control on a part of the page?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tea Maker
    New Member
    • Jul 2007
    • 45

    Can we validate a control on a part of the page?

    Hello .Net Experts,

    I am building an aspx page. Inside it, I have a Send Mail form, with controls: name, email and message and a "Send Mail" button.
    On another area of the page, I have another button, when clicking it, a dynamic image will change (It's ajax based).

    Now I have added a "RequiredFieldV alidator" to the "Email TextField" , to make sure the email is entered by the user before he press on "Send Mail".

    This is working amazingly, but the only problem is, if I don't want to send the email, instead, I would like to click the other button which change the image on the other side of the page, the image doesn't change, and I see the validator on the other side saying "Email Required!" .

    I definitely understand that this is happening because I should place the email, but is it possible to make an area for the validation, where we can work normally outside it without validation?

    Please suggest.

    Best regards,
    Wassim
  • SharpDeveloper
    New Member
    • Feb 2008
    • 12

    #2
    Hi Wassim
    You can use validationGroup Property of Validation Control for both controls like Email Address RequiredFieldVa lidator and The Send Mail button.

    Say You have btnSendMail (SendEmail), btnSendImage(Se ndImage) and reqFldvalid(Req uiredFieldValid ator) email address (textbox).

    1. Click the RequiredFieldVa lidator control and in the ValidationGroup property specify btnSendMail.
    2. Click the btnSendMail control and in the ValidationGroup property specify btnSendMail.

    Now run the page once you click the SendImage the validation won;t fire but once you click SendMail button you will see the error if the email address box is empty.

    Hope this helps.

    Originally posted by Tea Maker
    Hello .Net Experts,

    I am building an aspx page. Inside it, I have a Send Mail form, with controls: name, email and message and a "Send Mail" button.
    On another area of the page, I have another button, when clicking it, a dynamic image will change (It's ajax based).

    Now I have added a "RequiredFieldV alidator" to the "Email TextField" , to make sure the email is entered by the user before he press on "Send Mail".

    This is working amazingly, but the only problem is, if I don't want to send the email, instead, I would like to click the other button which change the image on the other side of the page, the image doesn't change, and I see the validator on the other side saying "Email Required!" .

    I definitely understand that this is happening because I should place the email, but is it possible to make an area for the validation, where we can work normally outside it without validation?

    Please suggest.

    Best regards,
    Wassim

    Comment

    • Tea Maker
      New Member
      • Jul 2007
      • 45

      #3
      Originally posted by SharpDeveloper
      Hi Wassim
      You can use validationGroup Property of Validation Control for both controls like Email Address RequiredFieldVa lidator and The Send Mail button.

      Say You have btnSendMail (SendEmail), btnSendImage(Se ndImage) and reqFldvalid(Req uiredFieldValid ator) email address (textbox).

      1. Click the RequiredFieldVa lidator control and in the ValidationGroup property specify btnSendMail.
      2. Click the btnSendMail control and in the ValidationGroup property specify btnSendMail.

      Now run the page once you click the SendImage the validation won;t fire but once you click SendMail button you will see the error if the email address box is empty.

      Hope this helps.

      Hello,

      I Followed the steps and it's working amazingly now.
      A million thanks for your help :)

      Best regards,
      Wassim

      Comment

      Working...