locked
2 instances of same User control RRS feed

  • Question

  • User-1060593267 posted

    Hi,

     

    I have 2 instances of same user control on 1 page. Each is activated by click of a separate button. My user control has a textbox and a button(say A). Textbox has a Required Field validator on it. It is validated on click of button A. When i click button A, i get the validation message twice. Is there a way to separate the validation of the same control based on the orginator of the user control?

     

    Thanks in advance! 

    Sunday, January 31, 2010 3:08 PM

Answers

  • User-1173903015 posted

    Change the ValdationGroup variable of the button and all the Validation controls to a unique ID,

    The best way to do this is to change it to the ID of the user control in it's load method.

    for example

    VB:
    Button1.ValidationGroup = me.ID

    C#:
    Button1.ValidationGroup = this.ID;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 31, 2010 7:09 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 3, 2010 2:47 PM

All replies

  • User-1173903015 posted

    Change the ValdationGroup variable of the button and all the Validation controls to a unique ID,

    The best way to do this is to change it to the ID of the user control in it's load method.

    for example

    VB:
    Button1.ValidationGroup = me.ID

    C#:
    Button1.ValidationGroup = this.ID;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 31, 2010 7:09 PM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 3, 2010 2:47 PM
  • User-1060593267 posted

    @frostfang: Thanks!!!  it worked.

    Wednesday, February 3, 2010 3:51 PM
  • User-1060593267 posted

    Thanks Raghav for the detailed info. 

    Wednesday, February 3, 2010 3:54 PM
  • User1281381861 posted

    Thanks Raghav for the detailed info. 

    My Pleasure.

    Wednesday, February 3, 2010 4:11 PM
  • User-1173903015 posted

    no worries, happy coding 

    Thursday, February 4, 2010 12:21 AM