1

I am using hidden field which stores lots of html which is generated in the page.

Below the hidden field there is a button named AddHtml which, when clicked, does some operation and stores html in the hidden field.

There is another button in the page which is loading data called loadData on click. So when I click AddHtml button then it moves loadData button somewhere up.

Here is my html:

 <div>

     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
            <script type="text/javascript">

                function doOperation(id, name) {
                    document.getElementById("<%= hdnFldSavedHTML.ClientID %>").value = document.getElementById("<%= divShowImages.ClientID %>").innerHTML;
            </script>


            <section id="ideas" class="container">

                <div id="divShowImages" class="row" style="" runat="server" >

                </div>

                 <div class="row" >
                    <div class="col-xs-12 col-sm-6 col-sm-offset-3 col-lg-4 col-lg-offset-4">
                        <a class="btn btn-default btn-block btn-lg load-more-ideas" href="#" role="button" id="loadData"  runat="server" OnServerClick="btnNextRec_Click">More data please</a>

                    </div>
                </div>
                <div>

                </div>
            </section>
             <asp:Button runat="server" ID="AddHtml" OnClick="btnSubmit_OnClick" style="display:none"/>

             <asp:HiddenField runat="server" ID="hdnFldSavedHTML" Value=""  />
        </ContentTemplate>

    </asp:UpdatePanel>

Update1

This is how I see the hidden field when it's rendered:

<input type="hidden" name="ctl00$ctl40$g_a71dea1c_8102_4358_8ef1_41e74c01a6cc$hdnFldSavedHTML" id="ctl00_ctl40_g_a71dea1c_8102_4358_8ef1_41e74c01a6cc_hdnFldSavedHTML" value="

        <article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 0px; top: 0px;&quot;><div class=&quot;image&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=1&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/1/256_ICMPP.PNG&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>f</strong><span class=&quot;name&quot;> ./kiran1</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(1,&amp;quot;spnLikeStartPage1&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage1&quot;>44</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=1&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=1&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-md-3 col-lg-2&quot; style=&quot;position: absolute; left: 510px; top: 0px;&quot;><div class=&quot;image-small&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=2&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/2/256_ICPPTX.PNG&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>fgfgfgfgfgfgfgf</strong><span class=&quot;name&quot;> ./Kiran2</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(2,&amp;quot;spnLikeStartPage2&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage2&quot;>62</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=2&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=2&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 765px; top: 0px;&quot;><div class=&quot;image&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=3&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/3/256_ICODS.PNG&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>s</strong><span class=&quot;name&quot;> ./dd</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(3,&amp;quot;spnLikeStartPage3&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage3&quot;>13</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=3&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=3&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-md-3 col-lg-2&quot; style=&quot;position: absolute; left: 1275px; top: 0px;&quot;><div class=&quot;image-small&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=4&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/4/256_ICONE.PNG&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>d</strong><span class=&quot;name&quot;> ./d</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(4,&amp;quot;spnLikeStartPage4&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage4&quot;>7</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=4&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=4&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 0px; top: 765px;&quot;><div class=&quot;quote quote-@@class&quot;><div class=&quot;inner&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=5&quot;><p><strong>dfdf</strong><span class=&quot;name&quot;> ./d</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(5,&amp;quot;spnLikeStartPage5&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage5&quot;>27</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=5&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=5&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 510px; top: 765px;&quot;><div class=&quot;quote quote-@@class&quot;><div class=&quot;inner&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=6&quot;><p><strong>dfdf</strong><span class=&quot;name&quot;> ./ffg</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(6,&amp;quot;spnLikeStartPage6&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage6&quot;>20</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=6&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=6&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 1020px; top: 765px;&quot;><div class=&quot;quote quote-@@class&quot;><div class=&quot;inner&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=7&quot;><p><strong>dfdf</strong><span class=&quot;name&quot;> ./dfd</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(7,&amp;quot;spnLikeStartPage7&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage7&quot;>16</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=7&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=7&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 0px; top: 1275px;&quot;><div class=&quot;image&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=8&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/8/ShadesOfBlue.jpg&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>dfdf</strong><span class=&quot;name&quot;> ./sssd</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(8,&amp;quot;spnLikeStartPage8&amp;quot;)&quot;><div class=&quot;like-idea  likedDivShowIdeaPage&quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage8&quot;>8</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=8&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=8&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 510px; top: 1275px;&quot;><div class=&quot;image&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=9&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/9/Peacock.jpg&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>sdsdsd</strong><span class=&quot;name&quot;> ./dfdffdf</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(9,&amp;quot;spnLikeStartPage9&amp;quot;)&quot;><div class=&quot;like-idea likedDivShowIdeaPage&quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage9&quot;>12</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=9&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=9&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-md-3 col-lg-2&quot; style=&quot;position: absolute; left: 1020px; top: 1275px;&quot;><div class=&quot;image-small&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=10&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/10/Roses.jpg&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>sdsd</strong><span class=&quot;name&quot;> ./sdsd</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(10,&amp;quot;spnLikeStartPage10&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage10&quot;>6</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=10&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=10&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-md-3 col-lg-2&quot; style=&quot;position: absolute; left: 1275px; top: 1275px;&quot;><div class=&quot;image-small&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=11&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/11/Peacock.jpg&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>sdsd</strong><span class=&quot;name&quot;> ./sds</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(11,&amp;quot;spnLikeStartPage11&amp;quot;)&quot;><div class=&quot;like-idea &quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage11&quot;>3</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=11&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=11&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article><article class=&quot;idea col-xs-12 col-sm-6 col-lg-4&quot; style=&quot;position: absolute; left: 1020px; top: 1785px;&quot;><div class=&quot;image&quot;> <a href=&quot;http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=12&quot;><img src=&quot;http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/12/SoftBlue.jpg&quot; alt=&quot;&quot;></a><div class=&quot;ide&quot;><a href=&quot;#&quot;><p><strong>sdsd</strong><span class=&quot;name&quot;> ./sds</span></p> </a><a href=&quot;#&quot; class=&quot;like-post&quot; onclick=&quot;increaseLikes(12,&amp;quot;spnLikeStartPage12&amp;quot;)&quot;><div class=&quot;like-idea likedDivShowIdeaPage&quot;><span runat=&quot;server&quot; class=&quot;count&quot; id=&quot;spnLikeStartPage12&quot;>13</span><span class=&quot;heart&quot;></span></div></a><a href=&quot;#&quot; onclick=&quot;return twet_click(400, 350, &amp;quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=12&amp;quot;)&quot; target=&quot;_blank&quot; class=&quot;some-share share-twitter&quot;><span class=&quot;icon-twitter&quot;></span></a><a href=&quot;#&quot; onclick=&quot;return fbs_click(400, 350, &amp;quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=12&amp;quot;)&quot; target=&quot;_blank&quot; title=&quot;Share This on Facebook&quot; class=&quot;some-share share-facebook&quot;><span class=&quot;icon-facebook&quot;></span></a></div></div></article>">
Nick Pierpoint
  • 17,641
  • 9
  • 46
  • 74
James
  • 1,827
  • 5
  • 39
  • 69
  • Since i don't know what ype of data are you saving, i need to ask if it's possible that the html store in the 'value' attribute of the hidden field has any unencoded `"` that could be making dirty the html and causing that effect? – frikinside Aug 21 '15 at 11:59
  • @frikinside see my update – James Aug 21 '15 at 12:04
  • Your value consists of unquoted HTML. The first `"` thus ends your `input`'s attribute, the next `>` ends your `input`, and then the rest of your former `value` starts to pour all over the page. ;) – fboes Aug 21 '15 at 12:12
  • @fboes so what can be done here? – James Aug 21 '15 at 12:16
  • You should HTML encode the `Value` when you're setting it... then decode it when placing into the visible element. Even if you don't use the full encoding, at least encode `<` and `>` – freefaller Aug 21 '15 at 12:18
  • @fboes that was my initial thought. But I make a simple html page with the input and value provide by OP and nothing inside the value is pouring anywhere. I think there's no problem with that either. – frikinside Aug 21 '15 at 12:18
  • I've just tested it, and setting the value to `hello world` results in the rendered value of `<b>hello world</b>`. How are you setting `Value`? – freefaller Aug 21 '15 at 12:23
  • @freefaller document.getElementById("<%= hdnFldSavedHTML.ClientID %>").value = document.getElementById("<%= divShowImages.ClientID %>").innerHTML; – James Aug 21 '15 at 12:26
  • So you're setting it and posting back? If so, you need to check encoding of the `<` character, as that is your issue. Ignore all the answers talking about `display` and `visibility` – freefaller Aug 21 '15 at 12:27
  • @freefaller how to encode and where? in my code behind i assign dynamic html i generate to hidden field. Then when i click AddHtml button i stored that html in javascript using document.getElementById("<%= hdnFldSavedHTML.ClientID %>").value = document.getElementById("<%= divShowImages.ClientID %>").innerHTML – James Aug 21 '15 at 12:34
  • @Happy - [see my answer](http://stackoverflow.com/a/32140618/930393), hope that helps – freefaller Aug 21 '15 at 12:43
  • @freefaller no it didnt helped :( – James Aug 21 '15 at 13:10

4 Answers4

1

display: none

This is what you want. The space taken up is irrelevant so long as the object is set to display: none

visibility: hidden

This is most likely what you have now, objects are not visible, but their tags, size, etc are entirely 'present' in the current page.

On the slight possibility that the issue is not related to this common CSS problem then I will edit/delete my answer. You haven't given much to go off of though.

insidesin
  • 735
  • 2
  • 8
  • 26
  • how can i set display none for hidden field? – James Aug 21 '15 at 11:59
  • I don't think is a display:noene/visibility:hidden issue. input type hidden know nothing about such things. – frikinside Aug 21 '15 at 12:00
  • Nothing to do with display vs visbility. It's due to non-encoded HTML within the `Value` of the hidden field element – freefaller Aug 21 '15 at 12:19
  • Yeah I added a heavy 'if' case at the bottom, because given the information in his post at the start I couldn't really narrow it down from a CSS class issue or the input elements. – insidesin Aug 21 '15 at 13:18
1

The problem is nothing to do with display, visible, etc... but due to lack of encoding of the < character.

Based on the comment by the OP...

how to encode and where? in my code behind i assign dynamic html i generate to hidden field. Then when i click AddHtml button i stored that html in javascript using document.getElementById("<%= hdnFldSavedHTML.ClientID %>").value = document.getElementById("<%= divShowImages.ClientID %>").innerHTML

I would recommend specifically encoding the < character before the text is saved into the hidden field, and the decoded when "loaded" from it.

For example, when you're saving the HTML into the hidden field, instead of...

document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value =
  document.getElementById("<%=divShowImages.ClientID%>").innerHTML

Have...

var html = document.getElementById("<%=divShowImages.ClientID%>").innerHTML;
html = html.replace("<","&lt;");
document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value = html;

And when you need to "load it", instead of...

document.getElementById("<%=divShowImages.ClientID%>").innerHTML = 
  document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value;

Have...

var html = document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value;
html = html.replace("&lt;","<");
document.getElementById("<%=divShowImages.ClientID%>").innerHTML = html;
freefaller
  • 19,368
  • 7
  • 57
  • 87
  • Nope doesnt solve the issue. Not sure if its something else. But if i remove hidden field then there is no issue. So there is something with that hidden field – James Aug 21 '15 at 13:04
-2

Just to add to insidesin answer, If you want to make it displayed again use

display : block

Also, make position : absolute;

Edit: I think the problem is not having position : absolute :)

Read up on display / visibility here, and here

Community
  • 1
  • 1
Manu Masson
  • 1,667
  • 3
  • 18
  • 37
-2

Try adding this css --

#hdnFldSavedHTML { position: absolute; top: 0; left: 0; }

Ravi Khandelwal
  • 718
  • 1
  • 5
  • 15