+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to get the HTML content of the page

How to get the HTML content of the page

11 posts, 0 answered
  1. Monika
    Monika avatar
    7 posts
    Registered:
    18 Oct 2007
    25 Aug 2008
    Link to this post
    Hi,

    I am having a scenario where I need to get the script of the page created by sitefinity.
    I mean I need the complete HTML of the page.I am not finding anyway to get it.

    Any idea??

    Monika
  2. rochak
    rochak avatar
    4 posts
    Registered:
    20 Aug 2008
    25 Aug 2008
    Link to this post
    Hi Monika,

    I am not an expert of Sitefinity but to my knowledge there is no HTML code for a page you create using sitefinity - it is "built on the Fly "

    You will have to create your pages using masterpages, templates, skins and controls/modules.


  3. Monika
    Monika avatar
    7 posts
    Registered:
    18 Oct 2007
    26 Aug 2008
    Link to this post
    Hi Rochak,

    I do understand that HTML is built on fly, but there should be some procedure so that I can trace the HTML content,if you have any idea let me know.


    Thanks,
    Monika
  4. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    26 Aug 2008
    Link to this post
    Monica

    Have you tried looking at using an HttpModule to maybe try and intercept the HTML that way?  I haven't tried it but there may be some merit looking there?

    Maybe if you let us know what you are planning to do with it after you get it might help?

    Thanks
    Sean
  5. Sonya
    Sonya avatar
    231 posts
    Registered:
    24 Sep 2012
    26 Aug 2008
    Link to this post
    Hi Monika,

    There are different ways in which you could achieve this. Could you please provide information about what you want to do with the data so that we could provide you with the most appropriate method?

    Looking forward to your response.

    Regards,
    Sonya
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Monika
    Monika avatar
    7 posts
    Registered:
    18 Oct 2007
    26 Aug 2008
    Link to this post
    Hi Sonya,

    I want to get the HTML contents of the page in a XML file.



    Thanks,
    Monika
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    01 Sep 2008
    Link to this post
    Hello Monika,

    You could get the HTML content of the page, parse it and then build an XML file (or string) with the parsed content. Here's how to take the HTML content of the page:

    1. Create a new class file in the App_Code named GetHtmlContent.cs. This class should inherit the InternalPage class.
    2. Override the Render method:
    protected override void Render(HtmlTextWriter writer) 
        HtmlTextWriter output = new HtmlTextWriter(new StringWriter()); 
        base.Render(output); 
        string outputString = output.InnerWriter.ToString(); 
        writer.Write(outputString); 
    The variable outputString will contain your HTML content.

    3. Open the file cmsentrypoint.aspx located in \[YourProject]\Sitefinity\ directory, and make sure it inherits the GetHtmlContent class:
    <%@ Page Inherits="GetHtmlContent" MasterPageFile="~/Sitefinity/Dummy.master" %> 

    Attached is the complete class file.
    You should now parse the string and take the parts you need for your XML string.

    I hope this helps.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Christian Calderon
    Christian Calderon avatar
    5 posts
    Registered:
    06 Nov 2009
    22 Jan 2010
    Link to this post

    Question: Is there a way of doing this but by calling the Server.Execute method?

    for instance:

            public static string GetPageOutput(string pageName)  
            {  
                HttpContext Context = HttpContext.Current;  
                StringWriter sw = new StringWriter();  
                 
                try 
                {  
                    pageName = Context.Request.ApplicationPath + "/" + pageName;  
                    Context.Server.Execute(pageName, sw);  
                    return sw.ToString();  
                }  
                catch (Exception ex)  
                {  
                    //return ex.Message + "\n" + ex.StackTrace;  
                    throw ex;  
                }  
            }  
     

    The Server.Execute does not work because it doesn't find the page in question (in case of a CMS page).

    I need this in order to send the some pages via email....

    Thanks in advance,
    Chris
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Jan 2010
    Link to this post
    Hi Christian Calderon,

    You could try using IndexInternalPageHandler and then call server.Execute as the sample below shows. You need to supply writer, url and pageId parameters. For culture you may return null.

    IndexInternalPageHandler pageHandler = new IndexInternalPageHandler(writer, this.url, this.pageId, this.culture);
     
    pageHandler.AppRelativeVirtualPath = context.Request.AppRelativeCurrentExecutionFilePath;
     
    server.Execute(pageHandler, writer, false);


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. Venkat
    Venkat avatar
    105 posts
    Registered:
    20 Nov 2008
    28 Oct 2010
    Link to this post
    Hi
    We are having a Rad Tab Strip Control associated with Rad MultiPage Control.

    Here I have a Group page and it is having some child pages.We are not showing this group page in navigation.

    I want to show all the child pages of that group page as tab items and the page content as the tab content on our home page.
    How can I get it done.?

    for now I am able to render all the child pages as the tab items from the sitemap ,I want to display the selected page content as the Multi page , Page View content.

    Is there any way to get the selected SiteMap Node --> Selected Page--> Selected Page Content--> Render it on the Multi Page control.

    I dont want to navigate away from my Home Page.

    Thanks
    Venkat
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Nov 2010
    Link to this post
    Hi Venkat,

    You can use iframe in each RadPageView and this is the easiest way to do this. Another option is making a WebRequest to the page and reading the response stream, but you will take care for the styling and loading of the images, css classes, scripts etc

    <telerik:RadPageView ID="RadPageView3" runat="server">
          <asp:Label runat="server" ID="RenderPageContent"></asp:Label>
    </telerik:RadPageView>


    WebRequest mywebReq ;
    WebResponse mywebResp ;
    StreamReader sr ;
    string strHTML ;
     
    mywebReq = WebRequest.Create("http://www.telerik.com/default.aspx");
    mywebResp = mywebReq.GetResponse();
    sr = new StreamReader(mywebResp.GetResponseStream());
    strHTML = sr.ReadToEnd();
    RenderPageContent.Text = strHTML;

    You can get the current node from SiteMap.CurrentNode;

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
11 posts, 0 answered