I have a requirement for sending the mail to Client with specific section say div of an aspx page. I have created a sample method which executes the page on server and returns the HTML markup in a StringBuilder object.
This works fine. Now, Just i want to get the HTML of Specific Div Content and not the Whole returned page content.
Code:
protected void ReadPage()
{
//StreamReader reader = new StreamReader(Server.MapPath("CompleteOrder.aspx"));
//string readFile = reader.ReadToEnd();
////*** somewhere in an aspx page - preferably a different one to the one you are emailing but doesnt have to be******
StringWriter pageContents = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(pageContents);
Server.Execute("CompleteOrder.aspx", htw);
MailBiz ObjMailBiz = new MailBiz();
string Username = Session["UserName"].ToString();
string email = Session["EmailID"].ToString();
string strSubject = "Test Mail";
bool issent = ObjMailBiz.SendEmail(Username, email, strSubject, pageContents.ToString());
if (issent)
{
//mail sent successfully
}
else
{
//failed to sent the mail
}
}
Just i want to know how to read specific Div content from this returned string ?
Eg: Read the div with id="content" (<div id='content'>some other innerdivs tables etc</div>)
Help Appreciated!