_XDocumentEventSink2_Event.OnLoad 이벤트
Microsoft Office InfoPath 2007 양식이 로드된 후 그러나 보기가 초기화되기 전에 발생합니다.
네임스페이스: Microsoft.Office.Interop.InfoPath.SemiTrust
어셈블리: Microsoft.Office.Interop.InfoPath.SemiTrust(microsoft.office.interop.infopath.semitrust.dll)
구문
Event OnLoad As _XDocumentEventSink2_OnLoadEventHandler
Dim instance As _XDocumentEventSink2_Event
Dim handler As _XDocumentEventSink2_OnLoadEventHandler
AddHandler instance.OnLoad, handler
event _XDocumentEventSink2_OnLoadEventHandler OnLoad
주의
이 이벤트 처리기를 사용할 때는 작업을 취소할 수 있습니다.
DocReturnEventObject 개체의 ReturnStatus 속성이 false로 설정되면 양식 로드가 취소됩니다. OnLoad 이벤트에 대한 코드에서 발생하는 오류가 무시되고 ReturnStatus 속성에 따라 작업이 실행됩니다. ReturnStatus 속성이 명시적으로 설정되어 있지 않으면 기본값 true가 사용됩니다.
![]() |
---|
OnLoad 이벤트가 발생하면 보기가 초기화되지 않고 보기에 사용되는 XSLT(XSL 변환)가 로드되지 않습니다. XDocument 개체는 OnLoad 이벤트가 발생할 때까지 XDocumentsCollection 컬렉션에 추가되지 않습니다. 그러나 OnLoad 이벤트가 실행되는 동안 XDocument 개체를 사용할 수는 있습니다. |
![]() |
---|
이 이벤트를 사용하려면 전체 신뢰 보안 수준이 필요합니다. 이 보안 수준을 설정하려면 InfoPath 디자인 창에서 도구 메뉴의 양식 옵션을 선택한 다음 보안 탭에서 전체 신뢰를 선택합니다. 전체 신뢰 양식을 설치하거나 디지털 서명을 해야 합니다. |
예제
다음 예제에서는 OnLoad 이벤트 처리기를 사용하여 양식에 디지털 서명을 했는지 여부를 확인합니다. 디지털 서명이 되어 있지 않으면 함수와 사용자 지정 함수를 함께 사용하여 일부 날짜 값을 초기화합니다.
[InfoPathEventHandler(EventType=InfoPathEventType.OnLoad)]
public void OnLoad(DocReturnEvent e)
{
// Avoid DOM updates when the document has been digitally signed.
if (thisXDocument.IsSigned)
{
return;
}
string today = thisXDocument.Util.Date.Today().ToString();
initializeNodeValue("/sls:salesReport/sls:date", today);
}
이 Onload 이벤트 처리기 예제는 initializeNodeValue와 setNodeValue라는 두 개의 사용자 지정 함수를 활용합니다.
private void initializeNodeValue(string xpath, string strValue)
{
IXMLDOMNode xmlNode = thisXDocument.DOM.selectSingleNode(xpath);
// Set the node value *ONLY* if the node is empty.
if (xmlNode.text == "")
{
setNodeValue(xmlNode, strValue);
}
}
private void setNodeValue(IXMLDOMNode xmlNode, string strValue)
{
if (xmlNode == null)
{
return;
}
// The xsi:nil needs to be removed before we set the value.
if (strValue != "" && xmlNode.attributes.getNamedItem("xsi:nil") != null)
{
xmlNode.attributes.removeNamedItem("xsi:nil");
}
// Setting the value would mark the document as dirty.
// Let's do that if the value has really changed.
if (xmlNode.text != strValue)
{
xmlNode.text = strValue;
}
}
참고 항목
참조
_XDocumentEventSink2_Event 인터페이스
_XDocumentEventSink2_Event 구성원
Microsoft.Office.Interop.InfoPath.SemiTrust 네임스페이스