Click or drag to resize
WordDocumentOpenDataRegion Method
Opens the specified DataRegion and returns a DataRegion object.

Namespace: Aceoffix.WordWriter
Assembly: Aceoffix (in Aceoffix.dll) Version: 5.0.0.1
Syntax
public DataRegion OpenDataRegion(
	string DataRegionName
)

Parameters

DataRegionName
Type: SystemString
The name of DataRegion.

Return Value

Type: DataRegion
Returns a DataRegion object.
Remarks

Opens the specified DataRegion and returns a DataRegion object.

Examples

Code example 1:The following code example shows how to call the OpenDataRegion method to open DataRegion and fill data into the specified location of Word document.

Before running the code, please make sure that you have inserted the bookmark "ACE_CompanyName" and the bookmark "ACE_ProductName" into the test.doc.

Aceoffix.WordWriter.WordDocument wd = new Aceoffix.WordWriter.WordDocument();
wd.DisableWindowSelection = true;
wd.DisableWindowRightClick = true;

wd.OpenDataRegion("CompanyName").Value = "Acesoft";
wd.OpenDataRegion("ProductName").Value = "Aceoffix";

AceoffixCtrl1.ServerPage = "aceoffix-runtime/server.aspx";
AceoffixCtrl1.Bind(wd);
AceoffixCtrl1.OpenDocument("doc/test.doc", Aceoffix.OpenModeType.docReadOnly, "Tom");

Code example 2:The following example shows how to set OpenModeType as docSumitForm and set the editable DataRegions within Word document. By running this code, user can only edit text in range specified by the "CompanyName" DataRegion and the "ProductName" DataRegion. Besides those editable ranges, the Word document is read-only.

If you want that your users can only input the specified values, you can define the JsFunction_OnWordDataRegionClick event. The event is used to trigger a select dialog box when user click the DataRegion.

Before running the code, please make sure that you have inserted the bookmark "ACE_CompanyName" and the bookmark "ACE_ProductName" into the test.doc.

Aceoffix.WordWriter.WordDocument wd = new Aceoffix.WordWriter.WordDocument();

wd.OpenDataRegion("CompanyName").Value = "Acesoft"; //Sets initial value
wd.OpenDataRegion("CompanyName").Editing = true;

wd.OpenDataRegion("ProductName").Editing = true;

AceoffixCtrl1.ServerPage = "aceoffix-runtime/server.aspx";
AceoffixCtrl1.Bind(wd);
AceoffixCtrl1.SaveDataPage = "savedata.aspx";
AceoffixCtrl1.JsFunction_OnWordDataRegionClick = "OnWordDataRegionClick()";
AceoffixCtrl1.OpenDocument("doc/test.doc", Aceoffix.OpenModeType.docSubmitForm, "Tom");
Please refer to the code example in the OpenDataRegion(String) method topic to learn how to get the values of these DataRegions when saving the document.
See Also