3rd party Slimee DatePicker:如何处理解析错误?
我需要使用提到的第三方日期选择器,当输入无效日期时它会引发异常。作者仅公开一个事件,该事件在成功解析时触发。在 ASP.NET 中,我如何捕获此错误并采取措施(例如设置标签的文本)?
I need to use the mentioned 3rd party datepicker and it throws an exception when an invalid date it entered. The author only exposes one event, which is fired when a successful parse takes place. How, in ASP.NET could I catch this error and do something about it, like set a label's text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在此处采用多种方法,就我个人而言,我会通过继承替换 TextChanged 事件的默认事件处理程序。
代码在设置过程中分配了一个via,不幸的是文本框是一个私有成员
,声明为
因此我们可以继承SlimeeLibrary.DatePicker
,然后重写EventHandler,引发一个新的解析错误事件。
公共事件 EventHandler OnDateParseError;
希望有帮助。我还没有检查它,但已经检查了史莱姆控制的代码,但抱歉不想设置代码项目帐户来下载它。显然,您需要更改 ASP.NET 用户控件引用才能使用新类。
There are a couple of approaches you can take here, personally I would replace the default event handler for the TextChanged event via inheritance.
The code assigns one via during the setup and unfortunately textbox is a private member
which is declared as
So we can inherit SlimeeLibrary.DatePicker
and then override the EventHandler raising a new parse error event.
public event EventHandler OnDateParseError;
Hope that helps. I haven't checked it but have examined the code for slimees control, but don't want to setup a code project account to download it sorry. You'll obviously need to change your ASP.NET usercontrol references to use the new class.