简体   繁体   English

asp.net更新面板条件更新如何工作?

[英]how asp.net update panel conditional update works?

I use VS2010,C# to develop a web app for a company, they want to have a music playing while user views their site, I've found some controls (flash and JavaScript) to play mp3 files, but the problem is that whenever there is a postback, music starts to play from beginning, and it is not good, music should continue playing, I've used an update panel with update mode set to conditional, then inserted my JavaScript mp3 player inside this update panel, but when page has a post back (caused by some buttons outside the update panel) my music starts from beginning! 我使用VS2010,C#开发一个公司的网络应用程序,他们希望在用户查看他们的网站时播放音乐,我发现了一些控件(flash和JavaScript)来播放mp3文件,但问题是每当有是一个回发,音乐开始播放,它不好,音乐应该继续播放,我使用更新模式设置为条件的更新面板,然后在我的更新面板中插入我的JavaScript MP3播放器,但当页面有一个回发(由更新面板外的一些按钮引起)我的音乐从一开始就开始了! I think setting update mode to conditional should update the update panel only when there is a postback caused by controls inside it, how can I prevent my JavaScript player from re-start when there is an outside postback? 我认为将更新模式设置为条件只应在内部控件引起回发时更新更新面板,如何在外部回发时阻止我的JavaScript播放器重新启动? should I use something else? 我应该用别的吗? what is going wrong here? 这里出了什么问题?

                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
<script type="text/javascript" language="JavaScript" src="http://www.phenomenontest.com/audio-player.js"></script>
<object type="application/x-shockwave-flash" data="http://www.phenomenontest.com/player.swf" id="audioplayer1" height="24" width="290">
<param name="movie" value="http://www.phenomenontest.com/player.swf"/>
<param name="FlashVars" value="autostart=yes&playerID=audioplayer1&soundFile=http://www.phenomenontest.com/silas.mp3"/>
<param name="quality" value="high"/>
<param name="menu" value="false"/>
<param name="wmode" value="transparent"/>
</object> 
                    </ContentTemplate>
                    </asp:UpdatePanel>

在更新面板中放置导致回发的按钮,并将UpdateMode设置为“始终”。

Try this: 尝试这个:

Put this code in 1 page audio.aspx 将此代码放在1页audio.aspx中

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>   
<script type="text/javascript" language="JavaScript" src="http://www.phenomenontest.com/audio-player.js"></script>
<object type="application/x-shockwave-flash" data="http://www.phenomenontest.com/player.swf" id="audioplayer1" height="24" width="290"> 
<param name="movie" value="http://www.phenomenontest.com/player.swf"/> 
<param name="FlashVars" value="autostart=yes&playerID=audioplayer1&soundFile=http://www.phenomenontest.com/silas.mp3"/> 
<param name="quality" value="high"/> 
<param name="menu" value="false"/> 
<param name="wmode" value="transparent"/> 
</object>


Put this code in Head of Main.aspx 将此代码放在Main.aspx的Head中

<frameset rows="1%,99%">
<frame src="Audio.aspx" />
<frame src="Page1.aspx" />
</frameset>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM