通过ID加载Ektron小部件? [英] Load Ektron widget by ID?

查看:108
本文介绍了通过ID加载Ektron小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关Ektron问题的帮助.

I am looking for some help with an Ektron problem.

这种情况是,我们有许多位于许多页面上的小部件.这些小部件均接受用户输入.当用户浏览填写表单的页面时,我们将其字段响应保存到会话状态对象中,然后将这些内容写入数据库. 当用户到达表单末尾时,我们希望以只读模式显示他们填写的所有小部件.这将充当摘要页面.

The scenario is that we have a number of widgets which sit on a number of pages. These widgets all take user input. As the user moves through the pages filling out the form we save their field responses into a session state object, these get written to a database later. When the user gets to the end of the form we want to display all the widgets that they have filled out in a read-only mode. This will act as a summary page.

通过查询字符串参数或CMS可编辑字段,我们可以轻松地将小部​​件上的每个输入控件设置为只读.我们还可以将用户响应从会话状态加载回小部件中.

We can easily set each input control on a widget to be read-only by way of a query string parameter or CMS editable field. We can also load the user responses back into the widget from session state.

我们遇到的问题是将CMS编辑的内容重新加载到小部件中.

What we are having an issue with is loading the CMS edited content back into the widget.

有没有一种方法可以重新加载以前查看过的小部件?也许是使用Ektron API的ID?

Is there a way that we can reload a previously viewed widget? Maybe by an id using the Ektron API?

我们已经使用了WidgetBase.Host对象,但是无法使其正常工作.我们还尝试将整个窗口小部件对象保存为会话状态,然后将其重新加载到另一页上,但这还行不通.

We have played around with the WidgetBase.Host object but haven’t been able to make it work. We have also tried saving a whole widget object in to session state and reloading it onto another page but this hasn’t worked also.

推荐答案

在您的代码中,
using Ektron.Cms.PageBuilder;
using Ektron.Cms.Widget;

In your code,
using Ektron.Cms.PageBuilder;
using Ektron.Cms.Widget;

// The CMS Content ID of the first page of your form. 
const long otherPageId = 1036;

PageModel pm = new PageModel();
PageData pd = null;
pm.Get(otherPageId, out pd, false);
foreach (Ektron.Cms.PageBuilder.WidgetData w in pd.Widgets)
{

    WidgetTypeData myWidgetType;
    IWidgetTypeModel typeModel = Ektron.Cms.Widget.WidgetTypeFactory.GetModel();
    typeModel.FindByControlURL(w.ControlURL, out myWidgetType);

    // you may have to prefix the ControlURL with "/Widgets/" + w.ControlURL
    UserControl myWidget = Page.LoadControl(w.ControlURL) as UserControl;

    // _host is your page's widget host controller. 
    _host.PopulateWidgetProperties(ref myWidget, ref myWidgetType, w.Settings);
}

现在,您可以在页面上添加myWidget.
如果要阅读其属性.首先,您需要窗口小部件的类型.在ASPX页面中,可以使用<%@ Reference Control="~/widgets/YourWidget.ascx" %>,然后在代码旁文件中,可以将控件的类型引用为widgets_YourWidget.您可以将cast myWidget输入为widgets_YourWidget

Now you can add myWidget to your page.
If you want to read its properties. First you need your widget's type. In your ASPX page, you can use <%@ Reference Control="~/widgets/YourWidget.ascx" %> Then in your code-beside file you can reference the control's type as widgets_YourWidget. You can type cast myWidget as widgets_YourWidget

这篇关于通过ID加载Ektron小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆