Ali_dotNet
Ali_dotNet

Reputation: 3279

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! 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? 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>

Upvotes: 0

Views: 939

Answers (2)

Vinod
Vinod

Reputation: 4882

Try this:

Put this code in 1 page 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

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

Upvotes: 1

Saurabh
Saurabh

Reputation: 5727

Put button which caused postback inside update panel and set the UpdateMode to "Always".

Upvotes: 1

Related Questions