我已经找到了这篇文章:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=181&AspxAutoDetectCookieSupport=1
但我有不同的情况。我在母版页中嵌入了一些 hiddenFields 并尝试将 dragPanel 的位置存储在其中。
我正在使用 javascript 来存储 dragPanel 的位置,然后当用户单击链接时,会加载新页面,但 dragPanel 会重置到起始位置。
有什么简单的方法可以做到这一点?
伪代码:
**this is in MasterPage.master**
function pageLoad()
{
// call the savePanelPosition when the panel is moved
$find('DragP1').add_move(savePanelPosition);
var elem = $get("<%=HiddenField1.ClientID%>");
if(elem.value != "0")
{
var temp = new Array();
temp = elem.value.split(';');
// set the position of the panel manually with the retrieve value
$find('<%=Panel1_DragPanelExtender.BehaviorID%>').set_location(new
Sys.UI.Point(parseInt(temp[0]),parseInt(temp[1])));
}
}
function savePanelPosition()
{
var elem = $find('DragP1').get_element();
var loc = $common.getLocation(elem);
var elem1 = $get("<%=HiddenField1.ClientID%>");
// store the value in the hidden field
elem1.value = loc.x + ';' + loc.y;
}
<asp:Button ID="Button1" runat="server" Text="Button"/>
<asp:HiddenField ID="HiddenField1" runat="server" Value="0"
但是,HiddenField在重定向页面 foo.aspx 中不可见