Use WorkSpace content controls in Ribbon events when it's on masterpage

Mar 29, 2011 at 1:37 PM

Hi,

I have a ribbon on my masterpage, and a workspace which has the different aspx pages as content.

I would like to be use my content controls (gridview, drowdowns, labels, textboxes, ...) when clicking on the Ribbon buttons.

How do I do this ? The click events of the ribbon are called inside the masterpage, not in the content page itself...

Mar 29, 2011 at 1:57 PM

Hi,

dont know what language youre using but i would do this in the load and init events of the aspx page... like so..

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

	If Not Page.IsPostBack Then

		Master.MainWorkSpace.SelectedAreaID = "Area_Administration"
         		Master.MainWorkSpace.SelectedItemID = "Item_GridView1"

         		Master.MainManager.AddInitScript("OfficeWebUI.Ribbon.ShowContext('ContextMyGridPage');")
         		Master.MainManager.AddInitScript("OfficeWebUI.Ribbon.ShowTab('TabMyGridTab');")

            End If

        End Sub

 In the Init construct the context menu referred to above..

        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

            Dim lNewContext As OfficeWebUI.Ribbon.RibbonContext = New OfficeWebUI.Ribbon.RibbonContext

            lNewContext.ID = "ContextMyGridPage"
            lNewContext.Text = "Modules"
            lNewContext.ContextColor = "orange"
            Master.MainRibbon.Contexts.Add(lNewContext)

            Dim INewTab1 As OfficeWebUI.Ribbon.RibbonTab = New OfficeWebUI.Ribbon.RibbonTab
            INewTab1.ID = "TabMyGridTab"
            INewTab1.Text = "My GridView Options"
            lNewContext.Tabs.Add(INewTab1)

            Dim INewGroup1 As OfficeWebUI.Ribbon.RibbonGroup = New OfficeWebUI.Ribbon.RibbonGroup
            INewGroup1.ID = "Group_Editing"
            INewGroup1.Text = "Editing"
            INewGroup1.ShowExpander = False
            INewTab1.Groups.Add(INewGroup1)

            Dim lNewGroup1Zone1 As OfficeWebUI.Ribbon.GroupZone = New OfficeWebUI.Ribbon.GroupZone
            INewGroup1.Zones.Add(lNewGroup1Zone1)

            Dim ItemCreate As OfficeWebUI.Ribbon.LargeItem = New OfficeWebUI.Ribbon.LargeItem
            ItemCreate.ID = "Item_Create"
            ItemCreate.Text = "<b>Create</b>"
            ItemCreate.ImageUrl = "~/Common/Images/32/icon93_32.png"
            lNewGroup1Zone1.Content.Add(ItemCreate)
            AddHandler ItemCreate.Click, AddressOf ItemCreate_Click

End Sub
You will notice on the last line in the init that you can add a handler and from there you can do what you want...
Hope it helps..