2014-09-21 82 views
0

最近,我在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"); 
    } 

请让我知道这是正确的做法。这是可以实现的吗?

感谢

回答

0

我认为,当我们使用的用户界面(aspx页面),我们不能传递参数运行的方法,而不是在处理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