asp.net path Problem Solving method _ practical skills

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.