During the OnLoad event, the View object is null. You can check for this to prevent any other event from running during the OnLoad event.
The following example will prevent the OnAfterChange event for my:field1 from being processed during the OnLoad event (notice the addition of the check for (null == XDocument.View):
function XDocument::OnLoad(eventObj)
{
XDocument.DOM.selectSingleNode("//my:field1").text = "Some Value";
}
function msoxd_my_field1::OnAfterChange(eventObj)
{
if(eventObj.IsUndoRedo || null == XDocument.View)
return;
XDocument.UI.Alert("OnAfterChange Event Processed");
}
Hope this helps!

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
OnAfterChange, because it takes much time when loading.
Thanks
Which event are you trying to prevent?

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
"Li" <Li@Li.com> wrote in message
news:#ifTc4TsEHA.904@TK2MSFTNGP11.phx.gbl...
Hi
When I load infopath, I copy data to infopath and it invokes infopathevent.
Can I set some attribute let it not invoke infopathevent?
Thanks
I already prevent these events running during the OnLoad, but still very
slow.
When I deleted all these events it much faster. I used C# not javascript.
Is it code which make infopath so slow?
Thank you for your help.
During the OnLoad event, the View object is null. You can check for this to
prevent any other event from running during the OnLoad event.
The following example will prevent the OnAfterChange event for my:field1
from being processed during the OnLoad event (notice the addition of the
check for (null == XDocument.View):
function XDocument::OnLoad(eventObj)
{
XDocument.DOM.selectSingleNode("//my:field1").text = "Some Value";
}
function msoxd_my_field1::OnAfterChange(eventObj)
{
if(eventObj.IsUndoRedo || null == XDocument.View)
return;
XDocument.UI.Alert("OnAfterChange Event Processed");
}
Hope this helps!

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
OnAfterChange, because it takes much time when loading.
Thanks
"Greg Collins [MVP]" <Greg.Collins_AT_InfoPathDev.com> wrote in message
news:uvCpKlwsEHA.1720@TK2MSFTNGP14.phx.gbl...
Which event are you trying to prevent?

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Hi
When I load infopath, I copy data to infopath and it invokes infopathevent.
Can I set some attribute let it not invoke infopathevent?
Thanks
Greg Collins [MVP] - 27 Oct 2004 23:02 GMT
It depends on what you are doing in your code. If you are making numerous DOM operations then that might be what is slowing you down. If you are loading a massive XML file or massive number of rows from a database, that will slow you down.
You need to start commenting things out one by one to find out what the problem is.
You should also look into using the Disable/EnableAutoUpdate() methods if you are doing numerous DOM operations in the OnLoad event handler.
This is what debugging is all about--cutting things out and putting them back in until you find out what's going on.
Good luck!

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
I already prevent these events running during the OnLoad, but still very
slow.
When I deleted all these events it much faster. I used C# not javascript.
Is it code which make infopath so slow?
Thank you for your help.
During the OnLoad event, the View object is null. You can check for this to
prevent any other event from running during the OnLoad event.
The following example will prevent the OnAfterChange event for my:field1
from being processed during the OnLoad event (notice the addition of the
check for (null == XDocument.View):
function XDocument::OnLoad(eventObj)
{
XDocument.DOM.selectSingleNode("//my:field1").text = "Some Value";
}
function msoxd_my_field1::OnAfterChange(eventObj)
{
if(eventObj.IsUndoRedo || null == XDocument.View)
return;
XDocument.UI.Alert("OnAfterChange Event Processed");
}
Hope this helps!

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
"Li" <Li@Li.com> wrote in message
news:ur7QV2wsEHA.3156@TK2MSFTNGP12.phx.gbl...
OnAfterChange, because it takes much time when loading.
Thanks
Which event are you trying to prevent?

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
"Li" <Li@Li.com> wrote in message
news:#ifTc4TsEHA.904@TK2MSFTNGP11.phx.gbl...
Hi
When I load infopath, I copy data to infopath and it invokes infopathevent.
Can I set some attribute let it not invoke infopathevent?
Thanks