Changing ContentPlaceholder control programically from the Master Page with VB

Last post 05-09-2008 4:39 PM by DotNetAdvisor. 5 replies.

Sort Posts:

  • Changing ContentPlaceholder control programically from the Master Page with VB

    05-09-2008, 3:23 PM

    Looking to swap out an image located in the contentplaceholder of a master page from a control (Imagebutton) located in the Masterpage. Findcontrol is getting errors that object ref is not set to a...

    the goal of the design is to have an image on the page change when i mouse over the control in the masterpage..

    I have seen alot of post going the other way, changing the object in the master page from the contentpage but I would like to go the other way?

    Thanks in advance for any help

    1idesigned 

  • Re: Changing ContentPlaceholder control programically from the Master Page with VB

    05-09-2008, 4:01 PM

    So the control you're trying to access is located in the contentplaceholder on your masterpage is that correct? 

  • Re: Changing ContentPlaceholder control programically from the Master Page with VB

    05-09-2008, 4:12 PM

    Yes. I have a master page with a imagebutton and a default page which has an image. 

  • Re: Changing ContentPlaceholder control programically from the Master Page with VB

    05-09-2008, 4:23 PM
    Answer

    Here's the thing.  If you place controls inside a contentplaceholder on a master page you're effectively saying this is the default layout I want for this place holder.  However, when your content page places a content control mapped to the contentplaceholder it overwrites all the controls in the masterpage which is why you're not able to find the control in code.  You'll need to move that control outside of the contentplaceholder if you plan to implement your own content on the content page.

  • Re: Changing ContentPlaceholder control programically from the Master Page with VB

    05-09-2008, 4:33 PM

    Yes that makes sense.  I guess I can place an image in the master above the contentplaceholder so the code behind and find the control and change it.

    Blinded by the trees

    Thanks I will try and see if this will work for the layout/design

  • Re: Changing ContentPlaceholder control programically from the Master Page with VB

    05-09-2008, 4:39 PM

    Excellent.  Hey can you mark this answered so I don't keep coming back to it?  Thanks. 

Page 1 of 1 (6 items)