在asp.net 1.1中如何使用“步步为赢气泡验证控件(Winsteps.Validator) ”谢谢!

cnxzwtc 2008-11-19 05:32:12
在asp.net 1.1中如何使用“步步为赢气泡验证控件(Winsteps.Validator) ”谢谢!
...全文
117 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnxzwtc 2008-11-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sarsico 的回复:]
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using System.Web;
6using System.Collections;
7using System.Xml;
8//该源码下载自www.51aspx.com(51aspx.com)
9
10namespace Winsteps.Validator
11...{
12
13 /**//// <summary>
14 /// 步步为赢气泡验证控件
15 /// 作者:walkman
16 /// 邮箱:winstepsc…
[/Quote]
谢谢!步步为赢气泡验证控件 没有asp.net 1.1的版本!在asp.net 1.1中引用,无法使用!有没有解决的办法?
sarsico 2008-11-19
  • 打赏
  • 举报
回复
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using System.Web;
6using System.Collections;
7using System.Xml;
8//该源码下载自www.51aspx.com(51aspx.com)
9
10namespace Winsteps.Validator
11...{
12
13 /**//// <summary>
14 /// 步步为赢气泡验证控件
15 /// 作者:walkman
16 /// 邮箱:winstepscn@163.com
17 /// QQ:27800640
18 /// </summary>
19 public class WinVal
20 ...{
21 私有成员#region 私有成员
22 private bool m_isAutoClose = true; //自动关闭
23 private bool m_isfilterClose = true; //是否淡出效果关闭
24 private int m_closeTime = 2500; //关闭等待时间,单位ms
25 private string m_filesFolder = "WinValidatorFiles";
26 private string m_winvalStyle = "rightpoptip";
27 private static List<WinValInfo> infoList = new List<WinValInfo>();
28 #endregion
29
30 属性#region 属性
31
32 /**//// <summary>
33 /// 是否自动关闭
34 /// </summary>
35 public bool IsAutoClose
36 {
37 set
38 {
39 m_isAutoClose = value;
40 }
41 get
42 {
43 return m_isAutoClose;
44 }
45 }
46
47 /**//// <summary>
48 /// 是否渐变关闭
49 /// </summary>
50 public bool IsFilterClose
51 {
52 set
53 {
54 m_isfilterClose = value;
55 }
56 get
57 {
58 return m_isfilterClose;
59 }
60 }
61
62 /**//// <summary>
63 /// 自动关闭等待的时间
64 /// </summary>
65 public int CloseTime
66 {
67 set
68 {
69 m_closeTime = value;
70 }
71 get
72 {
73 return m_closeTime;
74 }
75 }
76
77
78 /**//// <summary>
79 /// 控件资源文件夹的名称
80 /// </summary>
81 public string FilesFolder
82 {
83 set
84 {
85 m_filesFolder = value;
86 }
87 get
88 {
89 return m_filesFolder;
90 }
91 }
92
93 /**//// <summary>
94 /// 显示样式,如:rightpoptip、toppoptip、buttompoptip
95 /// </summary>
96 public string ValStyle
97 {
98 set
99 {
100 m_winvalStyle = value;
101 }
102 get
103 {
104 return m_winvalStyle;
105 }
106 }
107
108 /**//// <summary>
109 /// 当前控件的版本号
110 /// </summary>
111 public string Version
112 {
113 get
114 {
115 return "2008-2-14 Ver1.1";
116 }
117 }
118 #endregion
119
120 方法#region 方法
121 private void ReadXmlToHashTable()
122 {
123 string applicationPath = HttpContext.Current.Request.ApplicationPath;
124 if (applicationPath != "/")
125 {
126 applicationPath = applicationPath + "/";
127 }
128 string xmlfile = applicationPath + m_filesFolder + "/config.xml";
129 try
130 {
131 XmlDocument doc = new XmlDocument();
132
133 doc.Load(HttpContext.Current.Server.MapPath(xmlfile));
134 XmlNodeList nodes = doc.SelectNodes("//xmlRoot/Tips");
135 foreach (XmlNode node in nodes)
136 {
137 WinValInfo info = new WinValInfo();
138 XmlDocument doc2 = new XmlDocument();
139 doc2.LoadXml(node.OuterXml);
140 info.TipName = doc2.SelectSingleNode("//Tips/tipname").InnerXml;
141 info.TipCss = doc2.SelectSingleNode("//Tips/tipcss").InnerXml;
142 info.TipFolder = doc2.SelectSingleNode("//Tips/tipfolder").InnerXml;
143 info.TipJs = doc2.SelectSingleNode("//Tips/tipjs").InnerXml;
144 infoList.Add(info);
145 }
146 }
147 catch (Exception ex)
148 {
149 ClientDeal.JsAlert("加载“" + xmlfile + "”文件失败,请确定文件未损坏。\n 错误信息:" + ex.StackTrace, false);
150 return;
151 }
152 }
153
154 /**//// <summary>
155 /// 设置气泡验证控件,设置完之后才起作用
156 /// </summary>
157 public void SetValidator()
158 {
159 if (infoList.Count == 0)
160 ReadXmlToHashTable();
161
162 string applicationPath = HttpContext.Current.Request.ApplicationPath;
163 if (applicationPath != "/")
164 {
165 applicationPath = applicationPath + "/";
166 }
167 if (!Directory.Exists(HttpContext.Current.Server.MapPath(applicationPath + m_filesFolder)))
168 {
169 ClientDeal.JsAlert("加载“" + m_filesFolder + "”文件夹失败,请确定文件夹是否存在。",false);
170 return;
171 }
172
173 StringBuilder sb = new StringBuilder();
174 sb.Append("\n");
175 sb.Append("//步步为赢(http://www.winsteps.cn)气泡验证控件JS段开始" + "\n");
176 sb.Append("var __Win__IsAutoClose = " + m_isAutoClose.ToString().ToLower()+ ";\n");
177 sb.Append("var __Win__IsFilterClose = " + m_isfilterClose.ToString().ToLower() + ";\n");
178 sb.Append("var __Win__CloseWaitTime = " + m_closeTime.ToString().ToLower() + ";\n");
179 sb.Append("//Js段结束" + "\n");
180 ClientDeal.ExecuteJs(sb.ToString(),false);
181
182 bool havingstyle = false;
183 WinValInfo info = new WinValInfo();
184 for (int i = 0, k = infoList.Count; i < k; i++)
185 {
186 WinValInfo tmpinfo = (WinValInfo)infoList[i];
187 if (m_winvalStyle == tmpinfo.TipName)
188 {
189 info = tmpinfo;
190 havingstyle = true;
191 break;
192 }
193 }
194 if (!havingstyle)
195 {
196 ClientDeal.JsAlert("参数设置错误:该气泡验证控件没有“" + m_winvalStyle + "”的样式。", false);
197 return;
198 }
199 else
200 {
201 ClientDeal.IncludeCssFile(applicationPath + m_filesFolder + "/" + info.TipFolder + "/" + info.TipCss);
202 ClientDeal.IncludeJsFile(applicationPath + m_filesFolder + "/lib/common.js", false);
203 ClientDeal.IncludeJsFile(applicationPath + m_filesFolder + "/" + info.TipFolder + "/" + info.TipJs, false);
204 }
205 }
206
207
208 #endregion
209 }
210}
]

[用途:]
本程序能改善asp.net验证控件的显示效果,用比较人性化的气泡提示来替换掉原来枯燥的界面提示,并带有"关闭提示"的功能,有效的解决了一个输入框带多个验证控件时,显示错误提示信息不在同一个地方的缺陷,也有效解决了验证控件占用页面提示信息版面的缺陷。

[功能调整改进:]
1. 使用cs代码调用控件,不使用原来在aspx文件插入script代码的方式;
2. 效果提示增加到3种,分别为rightpoptip(右侧气泡)、toppoptip(头部气泡)、buttompoptip(底部气泡);
3. 增加提示自动关闭和淡出关闭效果;
4. 增加关闭等待时间控制;
5. 自动支持虚拟目录和站点;
6. 可扩展性,增加config.xml文件配置,可以自由扩展,但是注意:修改config.xml之后需要重启IIS,因为使用了缓存机制。

[使用方法:]
1. 将Winsteps.Validator.dll引入到项目
2. 将WinValidatorFiles文件夹拷贝到web项目的根目录下;
2. 在.cs文件加入引用using Winsteps.Validator;
3. 在Page_Load事件插入如下代码:

WinVal WinValInstance = new WinVal();
WinValInstance.SetValidator();

WinVal属性详解:
IsAutoClose:是否自动关闭 默认为true
IsFilterClose:是否渐变关闭 默认为true
CloseTime:自动关闭等待的时间,单位:毫秒 默认为2500
FilesFolder:控件资源文件夹的名称 默认为WinValidatorFiles
ValStyle:显示样式,如:rightpoptip、toppoptip、buttompoptip 默认为rightpoptip
Version:当前控件的版本号

[注意:]
本程序在asp.net2.0,IE6、Firefox2下通过,但不保证能适应所有浏览器,淡出效果在IE下可用。

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧