none
Page Layout and Event Handling RRS feed

  • Question

  • I need to have a button at the bottom of my content pages in my Sharepoint site which performs a specific action. I thought that the best solution would be a page layout with a ASP.Net button in it, so that every page created using this layout would have the button on it. The action to be performed is the same on every page.

     

    The problem is that I don't know where/how to add the event handling code for the button!! I guess this is not a good approach since I haven't found any approach like this on the Web but I don't know how to do it differently. What should I do?

     

    Thanks!

    Friday, January 4, 2008 7:57 PM

Answers

  • The approach I have used successfully in the past has been to create a user control, place it in the controltemplates folder, and reference it on your page layout.  Then you can use it like you would any other user control. With respect to code, you just need to create a code behind page for your user control.  I am assuming your assembly is already being deployed.

     

    Hope this helps,


    Dan

    Sunday, January 6, 2008 11:44 PM

All replies

  • Create a webcontrol and you can add a webcontrol on the page layout and assembly to the GAC.

    Madhur
    Saturday, January 5, 2008 3:46 AM
  • Another approach would be to create a custom class inheriting from LayoutsPageBase class (definition in the WSS SDK) which is the default base class for a Page Layout. In this class you could define your custom controls and their events.

    Saturday, January 5, 2008 9:03 PM
  • The approach I have used successfully in the past has been to create a user control, place it in the controltemplates folder, and reference it on your page layout.  Then you can use it like you would any other user control. With respect to code, you just need to create a code behind page for your user control.  I am assuming your assembly is already being deployed.

     

    Hope this helps,


    Dan

    Sunday, January 6, 2008 11:44 PM
  • Thanks for the replies!

     

    I used Dan's suggestion and it worked perfectly!

     

    Monday, January 7, 2008 7:21 PM