当您创建事件处理程序时,InfoPath 会在表单模板的主脚本文件中创建该事件处理程序的声明。在该事件处理程序的声明中,InfoPath 将 eventObj 用作传递到该事件处理程序的参数的名称。此参数包含与该事件处理程序关联的事件对象。例如,当您在设计模式下创建 OnLoad 事件时,InfoPath 会在脚本文件中创建 OnLoad 事件处理程序,然后打开 Microsoft 脚本编辑器 (MSE) (Microsoft 脚本编辑器 (MSE):一种编程环境,用来在 InfoPath 表单中创建、编辑和调试 Microsoft JScript 或 Microsoft VBScript 代码。),以便您可以向下面的事件处理程序声明中添加自己的脚本:
//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function or the name and number of arguments.
//=======
function XDocument::OnLoad(eventObj)
{
// Write your code here.
}
'=======
' The following function handler is created by Microsoft Office InfoPath.
' Do not modify the name of the function, or the name and number of arguments.
'=======
Sub XDocument_OnLoad(eventObj)
' Write your code here
End Sub
在为事件处理程序编写脚本时,可以使用由通过 eventObj 参数传递的事件对象所实现的属性和方法。例如,在下面的 OnBeforeChange 事件处理程序中,使用 DataDOMEvent 事件对象的 NewValue 属性来检查刚更改的域值。如果该域为空白,则使用 DataDOMEvent 事件对象的 ReturnMessage 属性在对话框中显示错误,而且 ReturnStatus 属性设置为 false,这表明不应当接受用户进行的更改。
function msoxd__myField_attr::OnBeforeChange(eventObj)
{
// Determine whether there is a new value.
if (eventObj.NewValue == "")
{
// The value is blank, so display an error message and roll back the changes.
eventObj.ReturnMessage = "You must supply a value for this field.";
eventObj.ReturnStatus = false;
return;
}
}
Sub msoxd_myField_attr_OnBeforeChange(eventObj)每个 InfoPath 事件对象都实现不同的属性和方法。
' Determine whether there is a new value.
If (eventObj.NewValue = "") then
'The value is blank, so display an error message and roll back the changes.
eventObj.ReturnMessage = "You must supply a value for this field."
eventObj.ReturnStatus = vbFalse
End If
End Sub
声明:欢迎各大网站转载本站文章,还请保留一条能直接指向本站的超级链接,谢谢!
第1页 | 第2页时间:2007-7-19 21:14:01,点击:0
上一篇:有关在自定义程序中使用InfoPath 2007 的..【声明】:以上文章或资料除注明为Office吧自创或编辑整理外,均为各方收集或网友推荐所得。其中摘录的内容以共享、研究为目的,不存在任何商业考虑。如有任何异议,请与本站联系,联系邮箱:thinkou@126.com,本站确认后将立即撤下。谢谢您的支持与理解!
相关评论