Problem setting content control with OpenXML SDK 2.0
I have a Word 2007 doc with content control, title and tag set t开发者_运维知识库o "Control1" and the 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 is displayed correctly, but when the InnerXml is set to "Y" it results in X being deleted from the document
精彩评论