none
Application Page: Web Permissions & PeopleEditor event handling RRS feed

  • Question

  • Hi everyone

     

    I am working on creating a custom application page for a specfic sharepoint implementation. The page dynamically creates a web (say 'W') under a given site collection (say 'S'). I am stuck at following 2 places:

     

    1. I need to be able to assign a site group from 'S' as a member of a site group in 'W'. For e.g. a group named 'Top Users' in 'S' would be assigned as 'Site Owner' of 'W'. Using object model, I only see a way to add a user to the 'Site Owner' group (as follows), but am not sure how to add a group to it.

    W.SiteGroups["Site Owner"].AddUser(SPUserObjectToBeAdded)

     

     

    2. The page has a PeopleEditor control and an OK button. The button is supposed to be enabled only when something a valid user has been entered in the PeopleEditor.

     

    I gained the required functionality by enabling the AutoPostBack for PeopleEditor and overriding the PreRender event. This event checks if a valid user has been entered. If yes, it enables the OK button. However the problem is that the event does not fire when I remove the user entry from the PeopleEditor. Hence, on removing the user entry the people editor would be blank however the OK button would still be active. Any other work arounds ??

     

     

    Any suggestions would be highly appreciated ...

     

    Thanks much

    Vikram

    Friday, June 20, 2008 9:12 AM

All replies

  • Hi Vikram,

     

    1.       About addition of site group – I don’t know if I understand correctly, but it seems like you want to add one sharepoint group as a member in another sharepoint group ? If this is what you are trying to do, this is not possible. You can try the same from MOSS UI also, and it will throw an error with appropriate message.

    Please explain if you are trying to do something else.

     

    2.       People picker has a property named “AllowEmpty”, have you tried using this ? ( Even I haven’t tried this one myself but looks useful from the name)

    As a work around you can always check for the count of resolved entities in OK button click. I do understand that this will be more of a server side validation and client experience can be better if some validation is possible client side itself.

     

    Code Snippet

     

    if (<PeopleEditorInstance>.ResolvedEntities.Count == 0)

     

     

     

     

    Friday, June 20, 2008 8:03 PM
  • Hi Rohit

     

    Thanks for your response.

     

    The "sharepoint group" part is correct, I understand that what i was trying is not achievable.

     

    Regarding the second point, The snippet that you posted is a server-side code. I am doing exactly this, however the issue is that the event doing this would not fire if someone deletes the entries in the people editor (coz it doesn't postback even when autopostback is 'true'), and hence the validation fails. Any suggestions there?

     

    Regards

    Vikram

    Monday, June 23, 2008 2:10 PM