我正在使用隐藏字段,它存储了在页面中生成的大量html。
在隐藏字段下方有一个名为AddHtml
的按钮,当点击该按钮时,会执行一些操作并将html存储在隐藏字段中。
页面中还有另一个按钮,用于在点击时加载名为loadData
的数据。因此,当我点击AddHtml
按钮时,它会向某处移动loadData
按钮。
这是我的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
这是我在渲染时看到隐藏字段的方式:
<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="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 0px; top: 0px;"><div class="image"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=1"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/1/256_ICMPP.PNG" alt=""></a><div class="ide"><a href="#"><p><strong>f</strong><span class="name"> ./kiran1</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(1,&quot;spnLikeStartPage1&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage1">44</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=1&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=1&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-md-3 col-lg-2" style="position: absolute; left: 510px; top: 0px;"><div class="image-small"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=2"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/2/256_ICPPTX.PNG" alt=""></a><div class="ide"><a href="#"><p><strong>fgfgfgfgfgfgfgf</strong><span class="name"> ./Kiran2</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(2,&quot;spnLikeStartPage2&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage2">62</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=2&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=2&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 765px; top: 0px;"><div class="image"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=3"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/3/256_ICODS.PNG" alt=""></a><div class="ide"><a href="#"><p><strong>s</strong><span class="name"> ./dd</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(3,&quot;spnLikeStartPage3&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage3">13</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=3&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=3&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-md-3 col-lg-2" style="position: absolute; left: 1275px; top: 0px;"><div class="image-small"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=4"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/4/256_ICONE.PNG" alt=""></a><div class="ide"><a href="#"><p><strong>d</strong><span class="name"> ./d</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(4,&quot;spnLikeStartPage4&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage4">7</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=4&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=4&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 0px; top: 765px;"><div class="quote quote-@@class"><div class="inner"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=5"><p><strong>dfdf</strong><span class="name"> ./d</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(5,&quot;spnLikeStartPage5&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage5">27</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=5&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=5&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 510px; top: 765px;"><div class="quote quote-@@class"><div class="inner"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=6"><p><strong>dfdf</strong><span class="name"> ./ffg</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(6,&quot;spnLikeStartPage6&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage6">20</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=6&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=6&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 1020px; top: 765px;"><div class="quote quote-@@class"><div class="inner"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=7"><p><strong>dfdf</strong><span class="name"> ./dfd</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(7,&quot;spnLikeStartPage7&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage7">16</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=7&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=7&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 0px; top: 1275px;"><div class="image"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=8"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/8/ShadesOfBlue.jpg" alt=""></a><div class="ide"><a href="#"><p><strong>dfdf</strong><span class="name"> ./sssd</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(8,&quot;spnLikeStartPage8&quot;)"><div class="like-idea likedDivShowIdeaPage"><span runat="server" class="count" id="spnLikeStartPage8">8</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=8&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=8&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 510px; top: 1275px;"><div class="image"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=9"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/9/Peacock.jpg" alt=""></a><div class="ide"><a href="#"><p><strong>sdsdsd</strong><span class="name"> ./dfdffdf</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(9,&quot;spnLikeStartPage9&quot;)"><div class="like-idea likedDivShowIdeaPage"><span runat="server" class="count" id="spnLikeStartPage9">12</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=9&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=9&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-md-3 col-lg-2" style="position: absolute; left: 1020px; top: 1275px;"><div class="image-small"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=10"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/10/Roses.jpg" alt=""></a><div class="ide"><a href="#"><p><strong>sdsd</strong><span class="name"> ./sdsd</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(10,&quot;spnLikeStartPage10&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage10">6</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=10&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=10&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-md-3 col-lg-2" style="position: absolute; left: 1275px; top: 1275px;"><div class="image-small"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=11"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/11/Peacock.jpg" alt=""></a><div class="ide"><a href="#"><p><strong>sdsd</strong><span class="name"> ./sds</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(11,&quot;spnLikeStartPage11&quot;)"><div class="like-idea "><span runat="server" class="count" id="spnLikeStartPage11">3</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=11&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=11&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article><article class="idea col-xs-12 col-sm-6 col-lg-4" style="position: absolute; left: 1020px; top: 1785px;"><div class="image"> <a href="http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=12"><img src="http://zle01066-dev002/sites/idebank/Lists/IdeBank/Attachments/12/SoftBlue.jpg" alt=""></a><div class="ide"><a href="#"><p><strong>sdsd</strong><span class="name"> ./sds</span></p> </a><a href="#" class="like-post" onclick="increaseLikes(12,&quot;spnLikeStartPage12&quot;)"><div class="like-idea likedDivShowIdeaPage"><span runat="server" class="count" id="spnLikeStartPage12">13</span><span class="heart"></span></div></a><a href="#" onclick="return twet_click(400, 350, &quot;https://twitter.com/intent/tweet?text=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=12&quot;)" target="_blank" class="some-share share-twitter"><span class="icon-twitter"></span></a><a href="#" onclick="return fbs_click(400, 350, &quot;http://www.facebook.com/share.php?u=http://zle01066-dev002/sites/idebank/Pages/Single.aspx?ItemId=12&quot;)" target="_blank" title="Share This on Facebook" class="some-share share-facebook"><span class="icon-facebook"></span></a></div></div></article>">
答案 0 :(得分:1)
这就是你想要的。只要对象设置为display: none
这很可能是你现在所拥有的,物体不可见,但它们的标签,大小等完全是“现在”。在当前页面。
关于这个问题与这个常见的CSS问题无关的可能性很小,那么我将编辑/删除我的答案。尽管如此,你还没有多大的帮助。
答案 1 :(得分:1)
问题与display
,visible
等无关......但由于缺少<
字符的编码。
基于OP的评论...
如何编码和在哪里?在我的代码后面我分配动态html我生成隐藏字段。然后,当我单击AddHtml按钮时,我使用document.getElementById(&#34;&lt;%= hdnFldSavedHTML.ClientID%&gt;&#34;)将该html存储在javascript中.value = document.getElementById(&#34;&lt;% = divShowImages.ClientID%&gt;&#34;)。innerHTML
我建议在将文本保存到隐藏字段之前专门编码<
字符,并在加载&#34;从它。
例如,当您将HTML保存到隐藏字段中时,而不是......
document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value =
document.getElementById("<%=divShowImages.ClientID%>").innerHTML
...有
var html = document.getElementById("<%=divShowImages.ClientID%>").innerHTML;
html = html.replace("<","<");
document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value = html;
当你需要&#34;加载&#34;而不是......
document.getElementById("<%=divShowImages.ClientID%>").innerHTML =
document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value;
...有
var html = document.getElementById("<%=hdnFldSavedHTML.ClientID%>").value;
html = html.replace("<","<");
document.getElementById("<%=divShowImages.ClientID%>").innerHTML = html;
答案 2 :(得分:-2)
只需添加到内部答案,如果要再次显示,请使用
display : block
另外,制作
position : absolute;
编辑:我认为问题不在于position : absolute
:)
答案 3 :(得分:-2)
尝试添加此css -
#hdnFldSavedHTML { position: absolute; top: 0; left: 0; }