Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Nov 01, 2011 @ 12:19
    Bo Damgaard Mortensen
    0

    Multiple macros with the same usercontrol

    Hi all,

    I'm having some trouble with one of my macros which contains a usercontrol. The usercontrol contains some textboxes with validation (asp.net validation) and a button for submitting the data.

    Now, the problem is that when a user places two or more of this macro on a page, it will validate all of the textboxes whenever a client clicks on one of the buttons. Of course, this is due to the asp.net controls having the same ID, but even if I try to, programatically, assign an unique id (using a GUID) to both the validation group, the controls and the validators, it still tries to validate all of the textfields.

    It feels like I have missed something really basic here, just can't see what it is. 

    Any help/hint is greatly appreciated!

    All the best,

    Bo

  • Rich Green 2246 posts 4008 karma points
    Nov 01, 2011 @ 13:07
    Rich Green
    0

    Hey Bo,

    I think this is a .NET issue right?

    You're using validation groups I assume? I think that you have to check that the group is vaild where as before you checked page.IsValid (my memories of .NET validation are a little rusty to be honest)

    Rich

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Nov 01, 2011 @ 16:14
    Bo Damgaard Mortensen
    0

    Hi Rich,

    Thanks for your reply :) Appreciated!

    I tried to perform a manual validation of the group, but with no result. I think the error is caused by assigning a new unique id to the controls and validation group before the actual validation when I click a button. Guess I have to rethink my structure as it's not pretty to have several asp.net controls with the same ID on the same page.

    Thanks again! :)

    - Bo

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Nov 01, 2011 @ 16:52
    Bo Damgaard Mortensen
    0

    Alright I finally came up with a solution to this!

    All I did was making a new unique string and assign it to a property on the usercontrol:

    UniqueId = Guid.NewGuid().ToString();

    public string UniqueId { get; set; }

    Then I set all of the controls validationgroup to this property and everything worked like it should!

    - Bo

Please Sign in or register to post replies

Write your reply to:

Draft