{"id":39,"date":"2011-04-12T11:05:35","date_gmt":"2011-04-12T01:05:35","guid":{"rendered":"http:\/\/www.reenadu.com\/?p=39"},"modified":"2011-04-12T11:05:35","modified_gmt":"2011-04-12T01:05:35","slug":"asp-net-dynamically-generate-ms-word-document-3","status":"publish","type":"post","link":"https:\/\/nickdu.com\/?p=39","title":{"rendered":"ASP.net dynamically generate MS Word document (3)"},"content":{"rendered":"<p>If you are following the previous two articles, you will see a \u201cWord\u201d document in your frond. However, you may find some glitches in this document and there is a hidden box on top of the document. This is because ASP.Net generates \u201c__VIEWSTATE\u201d hidden view to track each page status.<\/p>\n<p style=\"padding-left: 30px;\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2011\/04\/screenshot2.jpg\" alt=\"\" \/><\/p>\n<p>We don\u2019t want this field to be displayed as this should be a final \u201cWord\u201d document without any attached strings. To get rid of this, we have to override <em>Render<\/em> method.<\/p>\n<pre lang=\"csharp\">protected override void Render(HtmlTextWriter writer)\n{\n  StringBuilder sb = new StringBuilder();\n  HtmlTextWriter htw = new HtmlTextWriter(new StringWriter(sb));\n  base.Render(htw);\n  sb = sb.Replace(\"<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"rn__VIEWSTATE\" value=\"\" \/>\"\n        ,string.Empty);\n  writer.Write(sb.ToString());\n}\n<\/pre>\n<p>You should have a complete &#8220;Word&#8221; document right now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are following the previous two articles, you will see a \u201cWord\u201d document in your frond. However, you may find some glitches in this document and there is a hidden box on top of the document. This is because ASP.Net generates \u201c__VIEWSTATE\u201d hidden view to track each page status. We don\u2019t want this field &hellip; <a href=\"https:\/\/nickdu.com\/?p=39\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ASP.net dynamically generate MS Word document (3)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,2],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-net","category-it"],"_links":{"self":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39"}],"version-history":[{"count":0,"href":"https:\/\/nickdu.com\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions"}],"wp:attachment":[{"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nickdu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}