Customizing Parameter Settings Management Using OpenXML SDK 2.0

I have a Word 2007 document with content control, title and tag set to "Control1" and value "X". I am trying to change the value of Control1 to "Y"

  string sdtName = "Control1";
  SdtBlock sdt = mainPart.Document.Descendants<SdtBlock>()
            .Where(s =>
            s.GetFirstChild<SdtProperties>().GetFirstChild<Alias>().Val.Value
            .Equals(sdtName)).First();

  Response.Write(sdt.InnerXml);
  //results in X
  sdt.InnerXml = "Y";

      

X displays correctly, but when InnerXml is set to "Y" it causes X to be removed from the document

+2
c # ms-word openxml


source to share


No one has answered this question yet

Check out similar questions:

13
Replacing content controls in OpenXML
7
How can I change the content of a content control in Word 2007 using the OpenXML SDK 2.0?
2
Setting value in OpenXml checkbox word2013
2
Content controls in Word format
2
Text to docx (OpenXML SDK generated) uneditable
1
C # DocumentFormat OpenXML Word 2013 Repeating Content Control
0
C # OpenXML - How to set rich text string in content control and keep formatting
0
Programmatically add checkbox content controls to Word document using OpenXML
0
Find content control by TagName in Word document in OpenXml
-1
How to add bullet OpenXml list paragraph to content management?



All Articles
Loading...
X
Show
Funny
Dev
Pics