2

我已经找到了这篇文章:

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 中不可见

4

2 回答 2

1

与其将位置信息存储在隐藏字段中,不如将其存储在 cookie 中。信息很小,因此对页面加载性能的影响很小。

于 2008-09-16T19:58:34.057 回答
0

好的,所以我得到了拖动的东西,保存在数据库中,在我的一台显示器上显示很酷 1600X1050 一切都很好,很好,花花公子!可是等等!我在另一台 1366x768 显示器上打开了相同的页面,并且面板全部关闭。

保存功能以像素为单位保存,因此当您移至另一个“分辨率”时,面板会关闭。你知道吗?

PS我可以弹出一条消息,说明用户更改他们的显示器设置,大声笑...

于 2011-11-19T16:25:55.317 回答