Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Panel and Javascript

Status
Not open for further replies.

M8KWR

Programmer
Aug 18, 2004
864
GB
Hi

I am not so good with javascripts.

I have a page where I have added reference to javascript file eg <script src="../js/custom.js"></script>

I have an update panel that I need to refresh, but in there is elements that rely on the above JavaScript file to render chart controls etc - but on the partial postback it does not run

Any help would be appreciated.

I have tried several ways that I have found searching, but nothing seems to have an example that references a file, all the example I have found have the JavaScript within the page itself.
 
are you certain the file is getting included? is your JS directory in the root of the web application?
instead of a relative path, you might try including the js file using server side directive ...the tilde starts you at the root, so if your JS directory is somewhere else, use the tilde to start and fully qualify the directory path

two ways to do this... register your script in the code file during page_load
if(!Page.ClientScript.IsClientScriptIncludeRegistered("customjs"))
Page.ClientScript.RegisterClientScriptInclude("customjs", ResolveUrl("~/js/custom.js"));


if you want to register it in the aspx page like you were doing, use the directive inline like this
<script language='javascript' src='<%=ResolveUrl("~/js/custom.js")%>' type='text/javascript'></script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top