如何在页面加载之前移动asp.net/ajax控件?

时间:2020-12-30 02:01:50

I have an Panel control that I need to maintain position across postbacks. I am able to do this by maintaining a cookie which is read each time the page is loaded to get the position of the Panel before the page is loaded.

我有一个Panel控件,我需要在回发中保持位置。我可以通过维护一个cookie来实现这一点,每次加载页面时都会读取该cookie,以便在加载页面之前获取Panel的位置。

The problem is, the page is loaded, then repositioned which causes this brief flash where the control is at its default location and jumps to the location it was at prior to postback.

问题是,页面被加载,然后重新定位,导致这个简短的闪存,其中控件位于其默认位置,并跳转到回发之前的位置。

Is there a way to prevent this? I want the control to move to its position first, THEN have it displayed to prevent this "flash".

有办法防止这种情况吗?我希望控件首先移动到它的位置,然后显示它以防止这种“闪光”。

*edit: I am adding a DragPanel ajax control extender to reposition this. I have a pageLoad that is called and the Panel is repositioned after pageLoad is called. There's gotta be a really simple solution to this.

*编辑:我正在添加一个DragPanel ajax控件扩展器来重新定位它。我有一个被调用的pageLoad,并在调用pageLoad后重新定位Panel。对此必须有一个非常简单的解决方案。

3 个解决方案

#1


1  

Could you register the function that positions the panel in the pageLoad event of the ASP.NET client-side library?

你可以注册在ASP.NET客户端库的pageLoad事件中定位面板的函数吗?

This link may be helpful: ASP.NET AJAX Client Life-Cycle Events

此链接可能会有所帮助:ASP.NET AJAX客户端生命周期事件

#2


0  

Because you're storing the panel's location in a cookie, you could update the panel's location during the server side postback event.

因为您将面板的位置存储在cookie中,所以您可以在服务器端回发事件期间更新面板的位置。

#3


0  

Since you already have code to reposition the panel during pageLoad, you can add code on server side to hide the panel when IsPostback.

由于您已经有了在pageLoad期间重新定位面板的代码,因此您可以在服务器端添加代码以在IsPostback时隐藏面板。

On pageLoad, you'll need to add step to set panel.style.display='' after panel after reposition.

在pageLoad上,您需要在重新定位后添加步骤以在面板后设置panel.style.display =''。

#1


1  

Could you register the function that positions the panel in the pageLoad event of the ASP.NET client-side library?

你可以注册在ASP.NET客户端库的pageLoad事件中定位面板的函数吗?

This link may be helpful: ASP.NET AJAX Client Life-Cycle Events

此链接可能会有所帮助:ASP.NET AJAX客户端生命周期事件

#2


0  

Because you're storing the panel's location in a cookie, you could update the panel's location during the server side postback event.

因为您将面板的位置存储在cookie中,所以您可以在服务器端回发事件期间更新面板的位置。

#3


0  

Since you already have code to reposition the panel during pageLoad, you can add code on server side to hide the panel when IsPostback.

由于您已经有了在pageLoad期间重新定位面板的代码,因此您可以在服务器端添加代码以在IsPostback时隐藏面板。

On pageLoad, you'll need to add step to set panel.style.display='' after panel after reposition.

在pageLoad上,您需要在重新定位后添加步骤以在面板后设置panel.style.display =''。