Thanks Matthew I've done that before, but this isn't a custom section. It a dashboard and I don't know how to get the webcontrol which I need to add the button.
private static T FindControlRecursive<T>(Control parent, string id) where T : Control { if ((parent is T) && (parent.ID == id)) { return (T)parent; } return (from Control control in parent.Controls select FindControlRecursive<T>(control, id)).FirstOrDefault(foundControl => foundControl != null); }
Thanks for the code Dirk. This is how I solved it:
public partial class CreateNews : UserControl
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
var tabView = Page.FindControlRecursive<TabView>("dashboardTabs");
TabPage tabPage = (TabPage)tabView.GetPanels()[0];
ImageButton saveButton = tabPage.Menu.NewImageButton();
saveButton.ID = "ImgBtnSaveNews";
saveButton.Click += new ImageClickEventHandler(SaveButton_Click);
saveButton.AlternateText = "Save";
saveButton.ImageUrl = GlobalSettings.Path + "/images/editor/save.gif";
}
protected void SaveButton_Click(object sender, ImageClickEventArgs e)
{
//Todo save data.
//Show the bubble that the data has been saved.
BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.save, "Saved", "The data has been saved succesfully");
}
}
In this example I use my own version of FindControlRecursive which I already had :-). There is only one dashboard control so I need to fetch the first TabPage. I added this code inside the Dashboard usercontrol.
Dashboard tab buttons
Hello,
I'm creating a dashboard and above the dashboad there is always a tab. I'd like to add a save button to that tab. Does anyone have an example? Thanks.
Jeroen
Hi Jeroen,
This code is based on the Custom Section Video on Umbraco TV:
Hope it helps
Jeroen,
Firstly, use a page event to tap into the Load event of umbracoPage object.
Also check what page it actually is, as this event is firing for editContent/editMedia/dashboard.axps.
And then some code to add a button to the menu bar of a specific tab page. Parameter passed in is the page object from above code snippet
Hope this helps.
Cheers,
/Dirk
Thanks Matthew I've done that before, but this isn't a custom section. It a dashboard and I don't know how to get the webcontrol which I need to add the button.
Jeroen
Must say that I'm only having 2 dashboard controls and the second one is the one I had to add the button to... therefore the hardcoded
/Dirk
Sorry Jeroen, didn't read it properly, looks Like Dirk has provided the answer though!
Thanks for the code Dirk. This is how I solved it:
In this example I use my own version of FindControlRecursive which I already had :-). There is only one dashboard control so I need to fetch the first TabPage. I added this code inside the Dashboard usercontrol.
Jeroen
is working on a reply...