自定义Template,向其中添加新的panel
参考网站:https://www.devexpress.com/Support/Center/Example/Details/E2690
思路:
新建一个DefaultTemplate:
在新建的Template中进行自定义,在需要自定义的位置,加入PlaceHolder控件,这里加入的是XafUpdatePanel。这里以在右边加入一个XafUpdatePanel为例。
<td id="Right" width="250px" style="vertical-align: top">
<cc3:XafUpdatePanel ID="UPRight" runat="server"/>
</td>
界面如下:
为了实现能隐藏/显示Panel的功能,可以在Panel的左边加入一个分隔符。代码加入分隔符。
<td id="RS" style="width: 6px; border-bottom-style: none; border-top-style: none" class="dxsplVSeparator_<%= BaseXafPage.CurrentTheme %> dxsplPane_<%=BaseXafPage.CurrentTheme %>">
<div id="RSB" class="dxsplVSeparatorButton_<%=BaseXafPage.CurrentTheme%>" onmouseover="OnMouseEnter('RSB')" onmouseout="OnMouseLeave('RSB')" onclick="OnClick('Right','RSI')">
<div id="RSI" style="width: 8px;" class="dxWeb_splVCollapseForwardButton_<%=BaseXafPage.CurrentTheme %>">
</div>
</div>
</td>
这里介绍下该段语句的简单用法,onMouseEnter()和OnMouseLeave()传入的是id号为“RSB"的div元素的id,OnClick()第一个参数记录的是要隐藏的td元素的id号,在本例中,XafUpdatePanel位于id号为"Right"的元素中,通过隐藏该元素,即可隐藏Panel。ID为”RSI"的div元素放置的时隐藏/显示符号。“〉"为dxWeb_splVCollapseForwardButton。"<"为dxWeb_spVCollapseBackwardButton。请根据分隔符的位置设置。
同理,设置左边的PlaceHolder的代码如下:
<td id="leftPanel" width="250px" style="vertical-align: top">
<cc3:XafUpdatePanel ID="UPLeft" runat="server"/>
</td>
4 <td id="RL" style="width: 6px; border-bottom-style: none; border-top-style: none"
class="dxsplVSeparator_<%= BaseXafPage.CurrentTheme %> dxsplPane_<%= BaseXafPage.CurrentTheme %>">
<div id="RLT" class="dxsplVSeparatorButton_<%= BaseXafPage.CurrentTheme %>" onmouseover="OnMouseEnter('RLT')"
onmouseout="OnMouseLeave('RLT')" onclick="OnClick('leftPanel', 'RLI',true)">
<div id="RLI" style="width: 8px;" class="dxWeb_splVCollapseBackwardButton_<%= BaseXafPage.CurrentTheme %>">
</div>
</div>
</td>
完成Template的自定义工作后,要通过属性将新添加的XafUpdatePanel暴露出来。在CustomMainGISTemplate.ascx.cs中的类中添加代码如下:
#region Expose DefineControls
public System.Web.UI.Control RightPlaceHolder
{
get { return UPRight; }
}
public System.Web.UI.Control LeftPlaceHodler
{
get { return UPLeft; }
}
#endregion
注意,ASP.NET与WinForm在引用自定义模板的时候,有些许区别。在应用程序初始化时,默认页面就是Default.aspx。模板页(.ascx)是通过嵌入到Default.aspx中来实现的。因此,外部方法一般得通过Default.aspx文件的访问来获取customTemplate.ascx中的控件。这一点得注意。
接下来就是要定义一个外部访问接口,供XAF自动调用。
public interface InterfaceCustomGISTemplate:IFrameTemplate
{
Control RightPlaceHolder { get; }
Control LeftPlaceHodler { get; }
}
因为上一段讨论的原因,需要在Default.aspx.cs文件中,实现该接口,才可以让其它方法访问自定义的XafUpdatePanel。从而实现初始化等工作。
public partial class Default : BaseXafPage,InterfaceCustomGISTemplate
{
//......
#region Expose CustomControl
public Control RightPlaceHolder
{
get { return TemplateContent is customMainGISTemplate ? ((customMainGISTemplate)TemplateContent).RightPlaceHolder : null; }
}
public Control LeftPlaceHodler
{
get { return TemplateContent is customMainGISTemplate ? ((customMainGISTemplate)TemplateContent).LeftPlaceHodler : null; }
}
#endregion
}
接下来,就可以通过实现一个controller来完成在对应的XafUpdatePanel上添加控件并初始化等操作。XAF提供了一个CustomizeTemplateViewControllerBase<T>类,以帮助用户完成对自定义模板的初始化工作。用户只需继承该基类,并实现对应的接口即可。
具体代码如下:
public partial class GISInfoController : CustomizeTemplateViewControllerBase<InterfaceCustomGISTemplate>
{
//......
protected override void AddControlsToTemplateCore(InterfaceCustomGISTemplate template)
{
Control rightPlaceHolder = template.RightPlaceHolder;
if (rightPlaceHolder == null) return;
this.rightPanel = CreatePanel("rightPanel","InformationPanel");
licMsg = new LiteralControl("Used to show information or other related operation");
this.rightPanel.Controls.Add(licMsg);
rightPlaceHolder.Controls.Add(rightPanel); Control leftPlaceHolder = template.LeftPlaceHodler;
if (leftPlaceHolder == null) return;
this.leftPanel = CreatePanel("leftPanel", "DeviceSelectPanel");
mainTV = new DevExpress.Web.ASPxTreeView.ASPxTreeView();
mainTV.Nodes.Add("Add node");
leftPanel.Controls.Add(mainTV);
leftPlaceHolder.Controls.Add(leftPanel); } protected override void RemoveControlsFromTemplateCore(InterfaceCustomGISTemplate template)
{
Control rightPlaceHolder = template.RightPlaceHolder;
if (rightPlaceHolder == null) return;
rightPlaceHolder.Controls.Remove(rightPanel);
rightPanel = null;
licMsg = null; Control leftPlaceHolder = template.LeftPlaceHodler;
if (leftPlaceHolder == null) return;
leftPlaceHolder.Controls.Remove(leftPanel);
leftPanel = null;
mainTV = null;
} protected override void UpdateControls(View view)
{
licMsg.Text = licMsg.Text+string.Format("\nCurrent View Caption is:{0}", view.Caption);
} protected override void UpdateControls(object currentObject)
{ } }
最后,就是要把当前使用的默认模板替换成当前模板,具体在Global.asax中完成。
public class Global : System.Web.HttpApplication
{
//......
protected void Session_Start(Object sender, EventArgs e)
{
WebApplication.SetInstance(Session, new RMFSystemAspNetApplication());
WebApplication.Instance.Settings.DefaultVerticalTemplateContentPath = "Template/customMainGISTemplate.ascx";
//...... WebApplication.Instance.Setup();
WebApplication.Instance.Start();
}
}
生成界面如下:
自定义Template,向其中添加新的panel的更多相关文章
- Android自定义视图一:扩展现有的视图,添加新的XML属性
这个系列是老外写的,干货!翻译出来一起学习.如有不妥,不吝赐教! Android自定义视图一:扩展现有的视图,添加新的XML属性 Android自定义视图二:如何绘制内容 Android自定义视图三: ...
- Android下添加新的自定义键值和按键处理流程
Android下添加新的自定义键值和按键处理流程 说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我 ...
- android 添加新的键值,自定义按键-2【转】
本文转载自:http://blog.csdn.net/mr_raptor/article/details/8053871 在Android中,上层可使用的键值默认情况下是92个,从0-91:一般情况下 ...
- android 添加新的键值,自定义按键【转】
本文转载自:http://blog.csdn.net/mr_raptor/article/details/8053871 在Android中,上层可使用的键值默认情况下是92个,从0-91:一般情况下 ...
- Android下添加新的自定义键值和按键处理流程【转】
本文转载自: Android下添加新的自定义键值和按键处理流程 说出来不怕大家笑话,我写这篇博客的原因在于前几天去一个小公司面试Android系统工程师,然后在面试的时候对方的技术总监问了我一 ...
- Django实现自定义template页面并在admin site的app模块中加入自定义跳转链接
在文章 Django实现自定义template页面并在admin site的app模块中加入自定义跳转链接(一) 中我们成功的为/feedback/feedback_stats/路径自定义了使用tem ...
- Linux系统添加新用户
Linux系统中一般不直接使用root用户进行操作,需要添加新的用户. 首先,查看当前系统已有的用户 cat /etc/passwd 查看用户组 cat /etc/group 其次,添加想要的用户组和 ...
- 【译】Meteor 新手教程:在排行榜上添加新特性
原文:http://danneu.com/posts/6-meteor-tutorial-for-fellow-noobs-adding-features-to-the-leaderboard-dem ...
- magento -- 添加新产品时状态默认为激活,库存状态默认为有库存
添加新产品时状态默认为激活 打开文件/app/code/core/Mage/Catalog/Model/Product/Status.php,注释掉“Please Select” /** * Retr ...
随机推荐
- Activity传递对象的方法
//Serializeable传递对象的方法 public void SerializeMethod(){ Person mPerson = new Person(); mPerson.setName ...
- 【转】 [C/OC的那点事儿]NSMutableArray排序的三种实现(依赖学生成绩管理系统).
原文网址:http://blog.csdn.net/ministarler/article/details/17018839 c语言实现的学生成绩管理系统是面向过程的,而OC实现的学生成绩管理系统则是 ...
- Linux/Unix shell 脚本监控磁盘可用空间
Linux下监控磁盘的空闲空间的shell脚本,对于系统管理员或DBA来说,必不可少.下面是给出的一个监控磁盘空间空间shell脚本的样本,供大家参考. 1.监控磁盘的空闲空间shell脚本 robi ...
- c# is和as的区别
关于类型的判断和转换有is和as这2个操作符.具体区别和用法如下is就是处于对类型的判断.返回true和false.如果一个对象是某个类型或是其父类型的话就返回为true,否则的话就会返回为false ...
- Java 与无符号那些事儿
最近在使用 Java 作为 WebSocket 客户端连接 Node.js 的 WebSocket 服务器的时候,由于使用的客户端库比较老,所以遇到了字节符号的问题,上网查了一下,看到这篇文章写的很有 ...
- string中的substr() 和 find() 函数
string问题中经常遇到在stringA中查找stringB,主要通过substr()跟find()来完成 substr().find().replace() 都可以用一个位置加上一个长读去描述子串 ...
- ASP.NET MVC3 系列教程 - 部署你的WEB应用到IIS 6.0
I:ASP.NET MVC3 部署的前期工作 1.确认部署的服务器操作系统环境 首先我们确认服务器的操作系统版本 可以从系统命令行工具里输入: systeminfo 获取相关操作系统信息例如 然后再确 ...
- asp.net mvc下ckeditor使用
资源下载:ckeditor 第一步,引入必须文件“~/ckeditor/ckeditor.js” 第二步,替换文本域 <%: Html.TextArea("Content", ...
- IIS启动出错解决方法
IIS出现server application error,最终解决办法2007年10月30日 星期二 20:38Server Application Error The server has enc ...
- Hadoop 中疑问解析
Hadoop 中疑问解析 FAQ问题剖析 一.HDFS 文件备份与数据安全性分析1 HDFS 原理分析1.1 Hdfs master/slave模型 hdfs采用的是master/slave模型,一个 ...