在开发ASP.NET应用程序过程中编写Script是件很烦人的事情,其实我们可以把常用的Script装成相应的.NET组件在服务端调用,这样可以大大简化Script的编写还提高的Script的重用.
以下是常用的打开模式窗体并获取返回值的类调用,实际上可以给设置多个参数传入和不同控件获取不同返回值的结果.
定义打开窗体并设置返回值脚本类.
HFSoft.Web.Scripts.ShowModalDialog dialog=new HFSoft.Web.Scripts.ShowModalDialog(
XXX.Units.Config.WebBoot+"Appunit/WindowOpenDialog.aspx",
FrmFailureLogSearch.PageURI());
dialog.Height=400;
dialog.Width=600;
dialog.ReturnElements.Add(new HFSoft.Web.Scripts.ReturnElement(this.txtReturn.ClientID,"ReturnString"));
HFSoft.Web.Scripts.RegisterScript.RegiOnClick(cmdSearch,dialog);
打开窗体设置返回值的代码
HFSoft.Web.Scripts.ReturnValues returnValue=new HFSoft.Web.Scripts.ReturnValues();
returnValue.Add("ReturnString",filter);
HFSoft.Web.Scripts.RegisterScript.RegiPageClient(this,"return",returnValue);
打开窗体类的代码(其实很多Script都可以通过这样的方式来封装).
00006 namespace HFSoft . Web . Scripts
00007 {
00008 /// <summary>
00009 /// 创建打开窗体脚本类
00010 /// 注意:返回值参数据接收的数据格式必须
00011 /// key=value|key1=value1|.....
00012 /// </summary>
00013 public class ShowModalDialog : IExecuteScript
00014 {
00015 private const string _Dialog ="window.showModalDialog({0},' ',' dialogHeight : { 1 } px ;
dialogWidth : { 2 } px ; edge : Raised ; center : Yes ; help : No ; resizable : No ; status : No ; scroll :
Yes ;');" ;
00016 #region IExecuteScript 成员
00017 private bool mParent = false ;
00018 /// <summary>
00019 /// 是否需要加载父指向
00020 /// </summary>
00021 public bool Parent
00022 {
00023 get
00024 {
00025 // TODO: 添加 SetElementsValue.Parent getter 实现
00026 return mParent ;
00027 }
00028 set
00029 {
00030 // TODO: 添加 SetElementsValue.Parent setter 实现
00031 mParent = value ;
00032 }
00033 }
00034 private string GetParent ()
00035 {
00036 if ( Parent )
00037 return "parent." ;
00038 return "" ;










共有 0 位网友发表了评论,得分 0 分,平均 0 分 查看完整评论