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


source to share





All Articles