Link to home
Start Free TrialLog in
Avatar of antdow
antdow

asked on

Refreshing Javascript SRC Without Full PostBack

Dear All,

Please can someone kindly assist me with the following.

We have an ASP.NET Label (or Literal) Control where the Text property which is rendered to the page is a Javascript script tag with a SRC pointing to a remote URL (that inserts a video player).

We are trying to change the Text property of this control to a different javascript SRC value to render a different video but without having to POSTBACK the whole page.

Whilst the Text property of the label IS getting changed, the script tag is not getting re-rendered, i.e. the new video file is not getting called.

We have tried partial AJAX postback and dynamic creation of new control but to no avail.  The only way that we can get the new <script src> to re-render is to effect a full POSTBACK which is not ideal for other reasons.

I am guessing this should be possible.  Something in PAGE_LOAD must be doing this?

Thank you for your time.
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

This question requires some additional clarification.

An asp:Label whose Text property is a javascript script tag with a src pointing to a remote url?

I'm trying to get a mental picture of this.

Javascript script tag with a remote url for the src:
 <script type="text/javascript" src="http://remoteUrl.com"></script>

<asp:Label ID="whatever" Text="<script type='text/javascript' src='http://remoteUrl.com' />" runat="server" />

Why? It doesn't make sense.
Avatar of antdow
antdow

ASKER

Hi, and thank you for your response.

The URL looks something like this...

<script src="http://content.bitsontherun.com/players/nPripu9l-zNzx3xpv.js" type="text/javascript"></script>

The reason we are using this is that embedding this automatically provides us with a video player (JW Player) and loads a video (identified by the dynamically-generated ID).  This video is served by Bits On The Run, a Content Delivery Network.

Have tried a Label and Literal control.  Works perfectly EXCEPT when we try to refresh the dynamic value within the URL WITHOUT doing a full postback.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of antdow

ASKER

Thanks CodeCruiser, this was incredibly helpful in getting this to work.  Apologies for the delay accepting your solution.