1

I want to add java script file as a embedded resource file and i followed instructions mentioned in Here

[assembly: System.Web.UI.WebResource("SampleControl.UpdatePanelAnimation.js", "application/x-javascript", PerformSubstitution = true)]

Once the file is generated in HTML file display this added javascript file as follows:

<script src="/ScriptResource.axd?d=lyBGZNf7CGO603CCJNN8yTrjkoAldyy52iy559T1liheYL57VNFeGimuj8ohz4WEtG3M7F5mpO883thOOPBBT8UuRhleAeRuCd6qODUlQGDXzJGW4TK9TYCIXV9igRZ2M5X_-hyrlo8u3Dz5IHY-Pg2&amp;t=60342d3a" type="text/javascript"></script>

Instead of this dynamically generated name i need to add name something like this.

<script src="/ScriptResource.axd?d=UpdatePanelAnimation.js" type="text/javascript"></script>

How can i do this?

EDIT: My java script file is in separate project

0

1 Answer 1

2

you can use scriptmanager to create your own refernece in this manner:

<asp:scriptmanager runat="server">
    <scripts>
        <asp:scriptreference name="WebForms.js" assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" path="~/1.js">
        <asp:scriptreference name="MicrosoftAjaxWebForms.js" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" path="~/3.js">
        <asp:scriptreference name="MicrosoftAjax.js" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" path="~/4.js">
    </asp:scriptreference></asp:scriptreference></asp:scriptreference></scripts>

this will give HTML like this:

<script src="/DeAXDify/ScriptResource.axd?d=etBSwiV14lSQ0YmAEYFkRsEWCxZgNT44ZlBMp0-JG80D6vYrSWRwH-xgjsikUbq5SId1HBi_Zo1MRBZ--Iho5A2&t=1761aa8f" type="text/javascript"></script> 
<script src="1.js" type="text/javascript"></script> 
<script src="3.js" type="text/javascript"></script> 
<script src="4.js" type="text/javascript"></script>

you may find more info here: http://www.hanselman.com/blog/ASPNETAjaxScriptCombiningAndMovingScriptResourceaxdsToStaticScripts.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

my java script is in separate project. so i can't give path like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.