Saturday, February 19, 2011

how to access div tags of user control in master page

Can we access div tags of user control in Master page? I am trying to change the background color for each one of the div tags on some event.

From stackoverflow
  • The best way is to make a public property in the user control that you can then set directly from the masterpage.

    alice7 : I am trying to set the property from master page but nothing is happening to back ground color of div tag
  • Something like this should work (in C#):

    Control myControl = this.Page.Master.FindControl("[Your name here]");

    then you can do whatever you would like to the control. If it's a Panel control (for the div) you can cast it that way, or if you are using an HTML server side control, you can cast it that way.

  • this totally looks like yet another job for jQuery

0 comments:

Post a Comment