I have a web app that allows users to edit a table. I have overwritten the Render method so that this table (with the edits) is saved as a .html file which I later convert to an image. There are a few things I don't want in the image -- specifically two buttons and a DropDownList. Here is the rendered HTML of interest:
<div class="centered" id="selectReport">
<select name="Archives" onchange="javascript:setTimeout('__doPostBack(\'Archives\',\'\')', 0)" id="Archives" style="width:200px;">
<option selected="selected" value="Dashboard_Jun-2012">Dashboard_Jun-2012</option>
</select>
</div>
And here is the Render method:
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new StringWriter()))
{
base.Render(htmlwriter);
string renderedContent = htmlwriter.InnerWriter.ToString();
string output = renderedContent.Replace(@"<input type=""submit"" name=""viewReport"" value=""View Report"" id=""viewReport"" />", "");
output = output.Replace(@"<input type=""submit"" name=""redoEdits"" value=""Redo Edits"" id=""redoEdits"" />", "");
Regex regex = new Regex(@"<select name=""Archives""[.\\n]*(?<date>\\w{3}-\\d{4})[.\\n]*</select>");
Match match = regex.Match(output);
Response.Write(match.Success);
string date = match.Groups["date"].Value;
Regex.Replace(output, @"<select name=""Archives""[.\\n]*</select>", date);
writer.Write(renderedContent);
}
}
The two calls to Replace are working as expected and removing the two buttons. What I am attempting to do with the DropDownList is to replace it with the value it displays, however the pattern match is failing as Response.Write(match.Success) prints "False."
From my understanding this Regex should be working. Of course I have tried many alternatives but without any success.
Any advice is appreciated.
Regards.