最近我在sitecore内容编辑器上添加了一个按钮,因此用户可以单击该按钮进行特定操作。
当用户点击按钮时,aspx页面将作为弹出窗口加载。 aspx页面上也有按钮。
我想要做的是将一些值传递给类中的run方法,该方法来自Sitecore.Shell.Framework.Commands.Command,来自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");
}
请让我知道正确的方法。这可以实现吗?
由于
答案 0 :(得分:0)
我认为当我们使用用户界面(aspx页面)时,我们不能将参数传递给Run方法,而是在aspx页面的回发按钮上处理所需的代码。请参阅我的博客以获取完整示例http://sitecoreworld.blogspot.co.nz/2014/09/example-of-sitecore-command-template_21.html。如果您需要在自定义命令中处理回发帖,请使用JavaScript弹出窗口http://sitecoreworld.blogspot.co.nz/2014/09/example-of-sitecore-command-template.html