您的问题是,您在 UpdatePanel 完成后没有更新 JavaScript 代码。从您的页面获取 JavaScript 代码,我将其更改为:
$(document).ready(function ()
{
// set the handlers
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
// init on page load
PrettyPhotoInit();
});
function InitializeRequest(sender, args) {
}
function EndRequest(sender, args) {
// init again after the UpdatePanel
PrettyPhotoInit();
}
function PrettyPhotoInit()
{
$("a[rel^='prettyPhoto']").prettyPhoto();
/*$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:3000, autoplay_slideshow: true});
$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
changepicturecallback: function(){ initialize(); }
});
$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
changepicturecallback: function(){ _bsap.exec(); }
});*/
}
你的问题与这些类似:
- Gridview Jquery DatePicker 中的 Asp.Net UpdatePanel https://stackoverflow.com/questions/3341623/asp-net-updatepanel-in-gridview-jquery-datepicker/3341741#3341741
- jquery Accordion 在 asp.Net 回发后不会重新启动 https://stackoverflow.com/questions/13856717/jquery-accordion-not-re-initiating-after-an-asp-net-postback/13856997#13856997
你可能需要更多的改变;我不知道你调用了什么其他库或其他 JavaScript 文件,但这是总体思路。
而且你的视图状态也很大。通过关闭不需要的控件上的视图状态来减少它,并压缩它。
视频初始化:
这些页面使用“流动播放器 http://flowplayer.org/”来显示和播放视频。为了使其正常工作,您需要在通过 UpdatePanel 加载每个新内容后对 FlowPlayer 进行初始化。
您现在要做的就是随时调用脚本。这是您页面上的一行:
Now:
<a href='/2011108218271.flv' style='display:block;width:100%; height:201px' id='player_1184'></a>
<script> flowplayer('player_1184', '/flash/flowplayer-3.2.7.swf', {clip: {autoPlay: false,autoBuffering: true}});</script>
每个视频后面都有初始化它的脚本。这不能与 Ajax 一起使用,也不能与 UpdatePanel 一起使用,因为当您加载新内容时,整行就像文本,并且当您将其呈现在页面上时浏览器不会对其进行编译(JavaScript 将不会运行)。
正确的方法是编写video标签,并在页面完全加载时初始化视频。来自 ”初始化 http://flowplayer.org/docs/在 Flowplayer 的文档中,您需要将视频占位符定义为:
必须是这样的:
<div class="player" data-engine="flash">
<video preload="none">
<source type="video/x-flv" src="/2011108218271.flv"/>
</video>
</div>
每个视频都会有如上所述的一行,然后将所有行初始化为:
// install flowplayer to an element with CSS class "player"
$(".player").flowplayer({ swf: "/swf/flowplayer-.swf" });
最终代码将是:
$(document).ready(function ()
{
// set the handlers
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
// init on page load
PrettyPhotoInit();
InitFlowPlayer();
});
function InitializeRequest(sender, args) {
}
function EndRequest(sender, args) {
// init again after the UpdatePanel
PrettyPhotoInit();
// init again the videos
InitFlowPlayer();
}
function InitFlowPlayer()
{
// install flowplayer to an element with CSS class "player"
$(".player").flowplayer({ swf: "/swf/flowplayer-.swf" });
}
function PrettyPhotoInit()
{
$("a[rel^='prettyPhoto']").prettyPhoto();
/*$(".gallery:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:3000, autoplay_slideshow: true});
$(".gallery:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
changepicturecallback: function(){ initialize(); }
});
$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
changepicturecallback: function(){ _bsap.exec(); }
});*/
}