We have masterpage with DIV id="new-div". We have deployed a user control on this masterpage. I would like to know how can we access the new-div via the user control?

We need to add some css based on the logged in user and other details.

Is this possible?

  • do u know the id? Mar 21, 2014 at 11:55
  • Yes I do. Its a custom div that is created by myself on th4e master page with DIV ID="test1"
    – variable
    Mar 21, 2014 at 12:03
  • so @Unnie is correct. U can use jQuery and add a class on that div Mar 21, 2014 at 12:11

1 Answer 1


You can use jQuery for this.use the below script to add class in the user control.

var className='class1';//here write logic for   deciding the classname  .


  • but i want to write code in usercontrol based on some output value of SP object model list item value
    – variable
    Mar 21, 2014 at 11:42
  • i did not understand it can you explain this to me
    – variable
    Mar 21, 2014 at 12:14
  • You can write your logic to decide the className to be applied using server side code.Store that class value in a hiddenfield and using jquery assign the hiddenfield value to div .addClass method
    – Unnie
    Mar 21, 2014 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.