最近,我在sitecore內容編輯器上添加了一個按鈕,以便用戶可以單擊該按鈕進行特定操作。如何將值傳遞給sitecore中codebehind類的命令類?
當用戶點擊按鈕時,aspx頁面被加載爲彈出式winodw。 aspx頁面上也有按鈕。
我想要做的是將一些值傳遞給Sitecore.Shell.Framework.Commands.Command中的run方法,該方法來自按鈕單擊事件後面的aspx代碼。
的代碼如下:
//command class
public class DummyTickets : Sitecore.Shell.Framework.Commands.Command
{
/// <summary>
/// Overridable method from base class.
/// </summary>
/// <param name="context">command to be executed.</param>
public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context)
{
Sitecore.Context.ClientPage.Start(this, "Run", context.Parameters);
}
/// <summary>
/// The web form pops up in a new window.
/// </summary>
/// <param name="args"> pipeline args </param>
protected static void Run(ClientPipelineArgs args)
{
if (!args.IsPostBack)
{
var urlString = new UrlString(@"/sitecore modules/Shell/RSL/Dummy Tickets Generator/Dummytickets.aspx");
SheerResponse.ShowModalDialog(urlString.ToString(), "900", "800", string.Empty, false);
args.WaitForPostBack(true);
}
else
{
//get some values from codehind.....
if (args.HasResult)
{
if (Sitecore.Context.Item.Name == "Content Editor")
{
Sitecore.Context.ClientPage.ClientResponse.SetLocation(Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item));
}
}
}
}
}
//code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.ddlDraws.DataSource = this.GetCurrentDraws();
this.ddlDraws.DataTextField = "Title";
this.ddlDraws.DataValueField = "ArtUnionID";
this.ddlDraws.DataBind();
this.ddlDraws.Items.Insert(0, new ListItem("---Select draw---", "0"));
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDummyTickets_Click(object sender, EventArgs e)
{
//how to pass values to the command class when the user clicks the button.
SheerResponse.SetDialogValue("testing");
}
請讓我知道這是正確的做法。這是可以實現的嗎?
感謝