基于ASP.NET的JQueryUI控件开发(1) - JQueryScriptManager

  前面基本实现了ASP.NET MVC的 JQueryUI控件,现在准备写一套ASP.NET的JQueryUI控件开发,
  今天先写一个JQueryScriptManager的实现.(基于ASP.NET MVC的基础上进行的开发,最终写成的控件即可以应用于ASP.NET也可以应用于ASP.NET MVC).
  先上图:
  
  三个引入使用的是Bool类型属性,
  皮肤使用枚举类型,此类型在前面已定义: 一、实现 控件设计时显示JQuery Script Manager -htt://www.hahaman.cn效果 即可实现,
  二、设置功能实现:
  首先需要实现JQuery Script Manager 类中的属性 //属性定义
  public bool JQueryJs { get; set; }
  public bool JQueryUIJs { get; set; }
  public JQSkin Skins { get; set; }
  public bool JQueryLngZh_CN { get; set; }
  //初始化
  public JQueryManager()
  {
  this.JQueryJs = true;
  this.JQueryUIJs = true;
  this.JQueryLngZh_CN = true;
  this.Skins = JQSkin.smoothness;
  }
  //加载处理
  protected override void OnLoad(EventArgs e)
  {
  if (JQueryJs)
  this.Page.ClientScript.RegisterClientScriptInclude("jquery", Page.ClientScript.GetWebResourceUrl(typeof(JQueryUIExt), "Hahaman.Mvc.UI.jquery-1.4.2.min.js"));
  if (JQueryUIJs)
  {
  this.Page.ClientScript.RegisterClientScriptInclude("jqueryui", Page.ClientScript.GetWebResourceUrl(typeof(JQueryUIExt), "Hahaman.Mvc.UI.jquery-ui-1.8.2.custom.min.js"));
  string skin = Skins.ToString();
  Literal lit = new Literal();
  lit.Text = "/nskin + ".jquery-ui-1.8.2.custom.css") + "/" rel=/"stylesheet/" type=/"text/css/" />";
  this.Page.Header.Controls.Add(lit);
  }
  if (JQueryLngZh_CN)
  this.Page.ClientScript.RegisterClientScriptInclude("jquerylng", Page.ClientScript.GetWebResourceUrl(typeof(JQueryUIExt), "Hahaman.Mvc.UI.jquery.ui.datepicker-zh-CN.js"));
  }
  实现设计类:JQeryManagerDesigner public class JQeryManagerDesigner : ControlDesigner,IComponent
  {
  public JQeryManagerDesigner()
  : base() {
  }
  public override DesignerActionListCollection ActionLists
  {
  get
  {
  DesignerActionListCollection actionList
  = new DesignerActionListCollection();
  actionList.Add(new JQueryManagerActionList(base.Component));
  return actionList;
  }
  }
  #region IComponent 成员
  public event EventHandler Disposed;
  public ISite Site
  {
  get
  {
  throw new NotImplementedException();
  }
  set
  {
  throw new NotImplementedException();
  }
  }
  #endregion }
  ActionList类:JQueryManagerActionList public class JQueryManagerActionList : DesignerActionList
  {
  IComponent _parent;
  public JQueryManagerActionList(IComponent c)
  : base(c) {
  _parent = c;
  }
  private DesignerActionItemCollection items;
  public override DesignerActionItemCollection GetSortedActionItems()
  {
  if (items == null)
  {
  items = new DesignerActionItemCollection();
  items.Add(new DesignerActionHeaderItem("JQuery Script设置"));
  items.Add(new DesignerActionPropertyItem("JQueryJs", "引入JQuery.js"));
  items.Add(new DesignerActionPropertyItem("JQueryUIJs", "引入JQuery.UI.js"));
  items.Add(new DesignerActionPropertyItem("JQueryLngZh_CN","引入JQuery中文语言包"));
  items.Add(new DesignerActionPropertyItem("Skins", "皮肤"));
  }
  return items;
  }
  private JQueryManager JQueryManager
  {
  get
  {
  return (JQueryManager)_parent;
  }
  }
  public bool JQueryJs {
  get
  {
  return JQueryManager.JQueryJs;
  }
  set
  {
  PropertyDescriptor desc
  = TypeDescriptor.GetProperties(base.Component)["JQueryJs"];
  desc.SetValue(base.Component, value);
  }
  }
  public bool JQueryUIJs {
  get
  {
  return JQueryManager.JQueryUIJs;
  }
  set
  {
  PropertyDescriptor desc
  = TypeDescriptor.GetProperties(base.Component)["JQueryUIJs"];
  desc.SetValue(base.Component, value);
  }
  }
  public JQSkin Skins {
  get
  {
  return JQueryManager.Skins;
  }
  set
  {
  PropertyDescriptor desc
  = TypeDescriptor.GetProperties(base.Component)["Skins"];
  desc.SetValue(base.Component, value);
  }
  }
  public bool JQueryLngZh_CN {
  get
  {
  return JQueryManager.JQueryLngZh_CN;
  }
  set
  {
  PropertyDescriptor desc
  = TypeDescriptor.GetProperties(base.Component)["JQueryLngZh_CN"];
  desc.SetValue(base.Component, value);
  }
  } }
  最后需要对JQuery Script Manager 类进行声明. 即可以实现!
  待续....
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值