[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

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.
0
antdow
Asked:
antdow
  • 2
1 Solution
 
Tom BeckCommented:
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.
0
 
antdowAuthor Commented:
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.
0
 
antdowAuthor Commented:
Thanks CodeCruiser, this was incredibly helpful in getting this to work.  Apologies for the delay accepting your solution.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now