Quantcast
Channel: TX Text Control Community
Viewing all articles
Browse latest Browse all 1022

[OPEN] Can not change field or remove field with TX Text Control for Asp.net

$
0
0
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:

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);
            }

the field is added.

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 field first added has not been changed, but there is a new field (with text "xyz") added.

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);

            }

What's the problem? Do I use it correctly? We want to change the text field, does anyone tell me how to do it?

Viewing all articles
Browse latest Browse all 1022

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>