我有这个代码在web应用程序.cshtml文件中正常工作。但是,我需要能够将其转换为.ascx文件。如何将其转换为.ascx页面?
这是@using表情和被引起我的问题的ajax.beginform。
谢谢。
@{
ViewBag.Title = "Async File Upload";
}
<h2>Async File Upload</h2>
@using (Ajax.BeginForm("AsyncUpload", "dnndev.me/fileupload/Upload", new AjaxOptions() { HttpMethod = "POST" }, new { enctype="multipart/form-data"}))
{
@Html.AntiForgeryToken()
<input type="file" name="files" id="fu1"/>
<input type="submit" value="Upload File" />
}
<div class="progress">
<div class="progress-bar">0%</div>
</div>
<div id="status"></div>
<style>
.progress {
position:relative;
width:400px;
border:1px solid #ddd;
padding:1px;
}
.progress-bar {
width:0px;
height:20px;
background-color:#57be65;
}
</style>
@section scripts{
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
(function() {
var bar = $('.progress-bar');
var percent = $('.progress-bar');
var status = $('#status');
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentValue = '0%';
bar.width(percentValue);
percent.html(percentValue);
},
uploadProgress: function (event, position, total, percentComplete) {
var percentValue = percentComplete + '%';
bar.width(percentValue);
percent.html(percentValue);
},
success: function (d) {
var percentValue = '100%';
bar.width(percentValue);
percent.html(percentValue);
$('#fu1').val('');
alert(d);
},
complete: function (xhr) {
status.html(xhr.responseText);
}
});
})();
</script>
}
如果您使用剃刀语法,那么你可以创建一个局部视图(其中也有一个.cshtml语法)代替。除非你的意思是你想将这段代码移植到使用WebForms视图引擎的单独应用程序中? – ADyson
我想将此代码移植到不使用剃须刀的现有dotnetnuke模块。这是一个现有的.ascx页面。 – Chris
它甚至使用WebForms引擎或实际的旧式Web表单的MVC? – ADyson