I am using TX Text Control for Asp.net 22.0 Trial version doing a demo, I cannot edit the field or remove the field, does anyone know how to do it?
I added a TextControl called TextControl1.
I add a text field:
the field is added.
I want to change the text of the field:
the field first added has not been changed, but there is a new field (with text "xyz") added.
The remove function also does not work:
What's the problem? Do I use it correctly? We want to change the text field, does anyone tell me how to do it?
I added a TextControl called TextControl1.
I add a text field:
Code:
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
//var newField = new MergeField();
var newField = new TextField();
newField.Name = "New field";
newField.ID = 1234;
newField.Text = "Text Field: New field";
//tx.ApplicationFields.Add(newField.ApplicationField);
tx.TextFields.Add(newField);
byte[] data;
tx.Save(out data, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
TextControl1.Selection.Load(data, TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
}
I want to change the text of the field:
Code:
byte[] data;
TextControl1.SaveText(out data, TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
// load the byte array into a temporary ServerTextControl
// sample use case: store document in a database
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load(data, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
//var allFields = tx.ApplicationFields;
var allFields = tx.TextFields;
var foundField = allFields.GetItem(1234);
if (foundField != null)
{
foundField.Text = "xyz";
}
byte[] data2;
tx.Save(out data2, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
TextControl1.Selection.Load(data2, TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
}
The remove function also does not work:
Code:
byte[] data;
TextControl1.SaveText(out data, TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
// load the byte array into a temporary ServerTextControl
// sample use case: store document in a database
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
tx.Create();
tx.Load(data, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
//var allFields = tx.ApplicationFields;
var allFields = tx.TextFields;
var foundField = allFields.GetItem(1234);
if (foundField != null)
{
//tx.ApplicationFields.Remove(foundField, false);
tx.TextFields.Remove(foundField);
}
byte[] data2;
tx.Save(out data2, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
TextControl1.Selection.Load(data2, TXTextControl.Web.BinaryStreamType.InternalUnicodeFormat);
}