如何从javascript工作在c# .aspx文件,指向正确的文件夹/文件与href和src
How to get functions from a javascript working in c# .aspx file, pointing to the right folder/file with href and src
我有一个。aspx文件,我想在其中有一个文件上传器,我从这里得到的。有一些例子包括如何使其工作。当我测试它只做HTML和javascript,我可以让它工作,但当我试图让它与c#工作,我不能得到路径到。js文件的权利。
示例html/javascript文件如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="fileuploader.css" rel="stylesheet" type="text/css">
<style>
body {font-size:13px; font-family:arial, sans-serif; width:700px; margin:100px auto;}
</style>
</head>
<script src="fileuploader.js" type="text/javascript"></script>
<script>
function createUploader(){
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: 'do-nothing.htm',
debug: true
});
}
// in your app create uploader as soon as the DOM is ready
// don't wait for the window to load
window.onload = createUploader;
</script>
</body>
</html>
我想在下面的。aspx文件中得到它。.js和.css文件位于D:'svn'Web'Framework'Trunk'test.Web。Framework'Scripts'fileuploader的位置和。aspx文件位于D:'svn'Web'Healthcare'trunk'test.Web.Healthcare'Areas'Framework'Administration'Entity。我尝试做以下操作,但这给了我一个GET =1325724928825">http://localhost:1304/Administration/blue/en-gb/Entity/Index/~/Scripts/fileuploader/fileuploader.js?=1325724928825 404 (Not Found)错误:
<%@ Control Language="C#" Inherits="test.Web.Framework.Core.ViewUserControl<test.Web.Framework.Areas.Administration.Models.NoteModel>" %>
<% using (UI.koform(Model, null))
{ %>
<div class="ui-state-highlight ui-corner-all highlight" data-bind="visible: meta.message">
<span class="ui-icon ui-icon-info"></span><strong data-bind="text: meta.message">
</strong>
</div>
Subject:
<input type="text" data-bind="value:subject" />
<span data-bind="text: subject"></span>
<br />
Text:
<input type="text" data-bind="value:text" />
<br />
<!--
<a href="#" data-bind="click:function(){setvalues() }">set values</a>
-->
<div class="dialogButtons">
<button onclick="$('#<%:Model.meta.modelname%>').koform('submit');">
Save</button>
</div>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="~/Scripts/fileuploader/fileuploader.css" rel="stylesheet" type="text/css">
</head>
<div id="file-uploader-demo1">
<noscript>
<p>Please enable JavaScript to use file uploader.</p>
<!-- or put a simple form for upload here -->
</noscript>
</div>
"~/Scripts/fileuploader/fileuploader.css"
<script src="~/Scripts/fileuploader/fileuploader.js" type="text/javascript"></script>
<script>
function createUploader() {
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader-demo1'),
action: 'do-nothing.htm',
debug: true
});
}
// in your app create uploader as soon as the DOM is ready
// don't wait for the window to load
window.onload = createUploader;
</script>
<%}%>
很容易修复。用这样的东西替换你的文件…
<script src="<%=ResolveClientUrl("~/Scripts/fileuploader/fileuploader.js")%>" type="text/javascript"></script>
这将解析相对于你的web应用程序的根文件夹的URL。对样式表和其他引用执行同样的操作。
我经常使用这个,尤其是在母版页中。
相关文章:
- 将配置文件文件夹移动到sdcardfirefoxmobile14.0
- Grunt imagemin-观察多个文件/文件夹优化单个文件
- Angular 2-模型驱动的表单,带有输入文件(文件上传)
- 将整个JavaScript文件文件夹添加到HTML5应用程序缓存中
- HTML或JavaScript,如何找出程序文件文件夹的位置
- 使用 OS 在 JavaScript 中预置文件.文件
- 使用纯 JavaScript 创建文件/文件夹
- 基本脚本,它向自己发送一封包含从文件文件夹中随机选择的内容的邮件
- 巴贝尔节点不't编译时忽略指定的文件/文件夹
- 在以下场景中,如何使代码可用于多个文件文件对象
- Chrome拖放文件/文件夹不工作
- Bootstrap fileinput删除所有文件文件,而不是要删除的特定预览文件
- 如何在SonarQube 4.4's技术债务计算中忽略文件/文件夹?
- OneDrive for Business是否有客户端javascript库提供文件/文件夹选择器控件?
- 将文件从插件复制到配置文件文件夹
- 从sd卡复制目录到“文件”;文件夹中
- 逐行读取上传的文件.文件,使用cfs:gridfs存储)
- 配置grunt copy任务,排除文件/文件夹
- 用于检查CSS和JS文件文件夹的工具
- gruntjs:将文件+文件夹重命名为任务