Posted on 05/12/2017 16:37:01
1) RibbonBar with dialog window
Here is a very basic example of how to implement a ribbon bar add-in with a button that opens a dialog...
using Dynamicweb.Controls;
using Dynamicweb.Controls.Extensibility;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Security.UserManagement;
namespace MyRibbonBars
{
[AddInTarget(RibbonBarAddInTarget.UserManagement.UserEdit)]
public class UserEditRibbonBar : RibbonBarAddIn
{
public UserEditRibbonBar(RibbonBar ribbon) : base(ribbon)
{
}
public override void Load()
{
// Get the data from current context
var user = Ribbon.DataContext.DataSource as User;
if (user == null)
{
return;
}
// Add the dialog
var dialog = new Dialog()
{
ID = "MyCustomDialog",
Title = "Test Dialog"
};
AddWindow(dialog);
// Add some content to the dialog
var dialogContent = new System.Web.UI.HtmlControls.HtmlGenericControl("div")
{
InnerText = $"Hello! The username is: {user.UserName}"
};
dialog.Controls.Add(dialogContent);
// Add a ribbon bar button for opening the dialog
var group = Ribbon.CreateGroup("MyCustomTab", "MyCustomGroup");
var button = new RibbonBarButton()
{
Text = "Test Button",
OnClientClick = $"dialog.show('{dialog.ID}');"
};
group.AddItem(button);
}
}
}
2) Module implementation hasn't really changed.
In DW9 you can use module annotations, but it's just an alternative way of registering a module. You can find an example of that in the API documentation for ContentModule class.