Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Use of comment when retrieving a specific HTML content part of your compile aspx page

0.00/5 (No votes)
22 Dec 2010 1  
How to take screenshot of a particular part of Asp.Net page save it into the database
I have one requirement when developing a module.

I need to retrive HTML content of Budget part from the whole rendered HTML Page and save it in to database. This HTML content needs to displayed in a pop up window on the click of Details link of another page.

Firstly, I think by adding this Budget part into panel or div tag and then finding the budget part by the id of div/panel control be helful. However this Budget part also had div and panel cotrols inside it. So it is very difficult to get the indexOf ending div tag.

I got a very good solution for this. If you add <!-- Start Budget part --> and <!-- End Budget Part --> in your aspx code, you can get these comments in the compile page HTML code. Another comment like <%-- Start Budget part --%> <%-- End Budget part --%> will not occur in the compile page HTML.

Example.

int startind = strResult.IndexOf("<!-- Start Budget part -->");
strResult = strResult.Substring(startind);

int endind = strResult.IndexOf("<!-- End Budget part -->");

strResult = strResult.Substring(0, endind);


And thus I only need to find the indexof <!-- Start Budget part --> and <!-- End Budget Part --> and made a substring to retrieve the content.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here