Axapta 对话框验证
我在网上发现了一些关于在对话框中验证表单字段的帖子和文章,但我发现的示例似乎都无法正常工作。
有人可以发布一个完整、简洁的 x++ 代码示例,该示例生成一个包含单个文本字段的对话框,对其执行简单的验证(如果 text =“abc”),并且如果验证通过则关闭窗口(返回字段值)或如果验证失败,则会生成信息日志警告而不关闭对话框。
对于我们这些刚开始使用 x++ 的人来说,我认为拥有一个实际的工作示例将是一个很好的起点。
谢谢!
I've found several posts and articles around the net talking about validating form fields in dialogs, but none of the examples I've found seem to work properly.
Can someone post a complete, concise example of x++ code that generates a dialog containing a single text field, performs simple validation (if text = "abc") on it, and either closes the window (returning the field value) if validation passes or generates an Infolog warning without closing the dialog if validation fails.
For those of us just beginning in x++, I think it would be a great starting point to have an actual working example to build on.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是 AX 2009 中如何使用 RunBase 类构建简单对话框的示例。在其中,我创建了一个名为 DialogExample 的类并派生自 RunBase。要显示对话框,您只需运行该类,但通常这可以通过将 MenuItem 指向该类来完成。
通常,在这种情况下,需要运行的逻辑将被放入类的 run 方法中,然后在单击“确定”按钮时从 main 调用。由于 run 方法是一个实例方法,因此不需要 parm 方法来访问对话框上字段的值。
Here is an example in AX 2009 of how to build a simple dialog using the RunBase class. In it I create a class called DialogExample and derive from RunBase. To show the dialog you simply need to run the class, but typically this would be done by pointing a MenuItem at the class.
Typically in this scenario logic that needs to be run would be put in a run method on the class and then called into from main if the Ok button is clicked. Since the run method would be an instance method this gets rid of the need for the parm methods to access the value of the field on the dialog.
我知道这是一个老问题,但还应该注意的是,对于刚开始 AX 开发领域的人来说,AOT 中有很好的工作代码示例,请查找具有前缀“Tutorial_”的表单和类。
Tutorial_RunBaseForm 是 AOT 中的一个类,它可以满足您的需求。
I know this is an old question but it should also be noted that for people starting out in the world of AX development, there are great working code examples in the AOT, look for the Forms and Classes which have the prefix "Tutorial_".
Tutorial_RunBaseForm is a class in the AOT which gives you exactly what you need.