Loading an HTML page in order to store it in member variable

Last post 10-13-2008 8:50 AM by NC01. 4 replies.

Sort Posts:

  • Loading an HTML page in order to store it in member variable

    10-11-2008, 9:52 AM
    • Member
      point Member
    • EMoscosoCam
    • Member since 03-17-2008, 2:24 AM
    • Posts 9

    Hello

    I want to show a popwindow when the user double-clicks rows in a grid. This new window is very complex, so I intend to download it the first time but use the document.write() method for the following cases.

    Is it possible to store the HTML code of a page in a variable so I can reuse it?

    Thanks a lot.

  • Re: Loading an HTML page in order to store it in member variable

    10-11-2008, 10:07 PM
    Answer
    • All-Star
      20,638 point All-Star
    • A1ien51
    • Member since 05-06-2005, 6:46 PM
    • MD USA
    • Posts 3,790

    You can not use document.write after the page loads.

     If you want to only change a portion of the page, you either need to use DOM methods or innerHTML

     Eric

  • Re: Loading an HTML page in order to store it in member variable

    10-12-2008, 9:11 AM
    • All-Star
      74,857 point All-Star
    • NC01
    • Member since 08-26-2005, 3:33 PM
    • Posts 13,907
    • TrustedFriends-MVPs

    As Eric said you can't use document.write. Also attempting to store/restore a page's content (you could probably use Session variables, though I've never attempted that) would be very hard and memory expensive to the server. It is far easier to just add an asp:Label control to your markup and change that.

    <form id="Form1" method="post" runat="server">
     <asp:Label id="dynamicContentLabel" runat="server"></asp:Label>
    </form>

    Client-side:

    <script type="text/javascript">
    <!--
    function addDynamicContent()
    {
     var elementRef = document.getElementById('<%= dynamicContentLabel.ClientID %>');
     var yourDynamicContent = 'Hello world<br>';
     elementRef.innerHTML = yourDynamicContent;
    }
    // -->
    </script>

    Server-side:

    private void addDynamicContent()
    {
     string yourDynamicContent = "Hello world<br>";
     dynamicContentLabel.Text = yourDynamicContent;
    }

    NC...

  • Re: Loading an HTML page in order to store it in member variable

    10-12-2008, 9:31 AM
    • Member
      point Member
    • EMoscosoCam
    • Member since 03-17-2008, 2:24 AM
    • Posts 9

    Thanks.

    What I intend is to store the  HTML content of a child page in a javascript variable, so that I can clone it. That is, I would use the window.Open() method with a valid URL to download the original child page first; then somehow I would store this page's HTML in a string variable client-side. Next time I want a child page, I would use the window.Open() method without an URL and then use the document.write() method to create a clone of the first page. In other words, I want to use the original child page as a template.

    This is because the main page (the one that calls the child pages) has a grid, and I want that when the user clicks a row, a child page is displayed showing that row's same data, but in a different layout. As you can read, since I already have the row's data client-side, I do not need to return to the server for data that I already have in the client.

     

     

  • Re: Loading an HTML page in order to store it in member variable

    10-13-2008, 8:50 AM
    • All-Star
      74,857 point All-Star
    • NC01
    • Member since 08-26-2005, 3:33 PM
    • Posts 13,907
    • TrustedFriends-MVPs

    Good luck with that. Seems like a lot of work for nothing. Also remember that no server-side code will be executed when doing that.

    NC...

     

Page 1 of 1 (5 items)