码迷,mamicode.com
首页 > Web开发 > 详细

Ext.Net 学习随笔 003 Panel基本使用

时间:2016-06-28 02:03:32      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:

Panel()

1.使用Content和Html属性设置Panel内容

技术分享

 前台View代码

@(X.Panel()
        .ID("panel1")
        .Width(350)
        .Height(200)
        .Title("Html")
        .BodyPadding(5)
        .Content(c=>DateTime.Now.ToString())
        .Buttons(
            X.Button()
            .Text("使用Content属性")
            .DirectEvents(de =>
            {
                de.Click.Url = Url.Action("SetHtmlProperty");
                de.Click.ExtraParams.Add(new Parameter("containerId", "panel1"));
            })
        )
    )

按钮Click事件后台代码

public ActionResult SetHtmlProperty(string containerId)
{
    this.GetCmp<Panel>(containerId).Html = DateTime.Now.ToString();
    return this.Direct();
}

2.使用Loader的Html模式从服务器获取Panel内容

技术分享

View中的代码

@(X.Panel()
    .ID("panel2")
    .Width(350)
    .Height(200)
    .Title("Loader with Html mode")
    .BodyPadding(5)
    .Loader(
        X.ComponentLoader()
        .Url(Url.Action("RenderChild"))
        .Mode(LoadMode.Html)
        .LoadMask(lm=>lm.ShowMask = true)
    )
    .Buttons(
        X.Button()
        .Text("SetLoaderProperty")
        .DirectEvents(de =>
        {
            de.Click.Url = Url.Action("SetLoaderProperty");
            de.Click.Method = HttpMethod.GET;
            de.Click.ExtraParams.Add(new Parameter("containerId", "panel2"));
        }),
        X.Button()
        .Text("LoadHtmlContent")
        .DirectEvents(de =>
        {
            de.Click.Url = Url.Action("LoadHtmlContent");
            de.Click.ExtraParams.Add(new Parameter("containerId", "panel2"));
        })
    )
)

后台Button事件

public ActionResult SetLoaderProperty(string containerId)
{
    var panel = this.GetCmp<Panel>(containerId);
    panel.Loader = new ComponentLoader
    {
        Url = Url.Action("RenderChild"),
        DisableCaching = true
    };
    panel.Loader.SuspendScripting();
    panel.LoadContent();

    return this.Direct();
}

public ActionResult LoadHtmlContent(string containerId)
{
    this.GetCmp<Panel>(containerId).LoadContent("RenderChild", true);
    return this.Direct();
}

3.使用Loader的Frame模式从服务器获取Panel内容

技术分享

View中代码

@(X.Panel()
    .ID("panel3")
    .Width(350)
    .Height(200)
    .Title("Loader with Frame mode")
    .BodyPadding(5)
    .Loader(
        X.ComponentLoader()
        .Url(Url.Action("RenderChild"))
        .Mode(LoadMode.Frame)
        .LoadMask(lm=>lm.ShowMask = true)
    )
    .Buttons(
        X.Button()
        .Text("SetIFrameLoadProperty")
        .DirectEvents(de =>
        {
            de.Click.Url = Url.Action("SetIFrameLoadProperty");
            de.Click.Method = HttpMethod.GET;
            de.Click.ExtraParams.Add(new Parameter("containerId", "panel3"));
        }),
        X.Button()
            .Text("LoadIFrameContent")
            .DirectEvents(de =>
            {
                de.Click.Url = Url.Action("LoadIFrameContent");
                de.Click.ExtraParams.Add(new Parameter("containerId", "panel3"));
            })
    )
)

后台Button事件

public ActionResult SetIFrameLoadProperty(string containerId)
{
    Panel panel = this.GetCmp<Panel>(containerId);
    panel.Loader = new ComponentLoader
    {
        Url = Url.Action("RenderChild"),
        DisableCaching = true,
        Mode = LoadMode.Frame
    };
    panel.Loader.SuspendScripting();
    panel.LoadContent();
    return this.Direct();
}

public ActionResult LoadIFrameContent(string containerId)
{
    this.GetCmp<Panel>(containerId).LoadContent(new ComponentLoader
    {
        Url = Url.Action("RenderChild"),
        DisableCaching = true,
        Mode = LoadMode.Frame
    });
    return this.Direct();
}

 

Ext.Net 学习随笔 003 Panel基本使用

标签:

原文地址:http://www.cnblogs.com/haight/p/5622009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!