But some static content, and the path to some script files, if referenced in a custom control, then the custom control will be referenced in a different motherboard page, or in a different directory. That would inevitably be the path problem.
The solution is also simple:
Copy Code code as follows:
Script language= "javascript" type= "Text/javascript" src= ' <%=resolveurl ("~/js/media.js")%> ' ></script >
<%=resolveurl ("~/js/media.js")%> ' > is exactly the output method that asp.net gets the absolute path.
Other:
If the path problem exists in the JavaScript script
The content has been written in the background:
Copy Code code as follows:
protected void Page_Load (object sender, EventArgs e)
{
String swf = ResolveUrl ("~/images/flash_menu20090430.swf");
String Menu =resolveurl ("~/menu.xml");
String list = ResolveUrl ("~/list.xml");
This. Literal1.text = "var swf=\" "+ swf +" \ "var menu=\" + menu + "\" var list=\ "" + list + "\";
}
Use the literal control in the script script:
Copy Code code as follows:
<script type= "Text/javascript" ><!--
<asp:literal id= " Literal1 "runat=" server ></asp:Literal>
var so = new SWFObject (swf, "Mymovie", "948", "307", "8", "#ffffff" );
So.addvariable ("Menuurl", Replacemystr (menu));
So.addparam ("wmode", "opaque");
So.addvariable ("listURL", Replacemystr (list));
So.write ("flashkv");
//--></script>