Ich habe diesen Code in einer Webanwendung .cshtml-Datei in Ordnung. Allerdings muss ich dies in eine .ascx-Datei konvertieren können.Wie konvertiere ich dies in eine .ascx-Seite?
Es sind die @ using Ausdrücke und die ajax.beginform, die mir die Probleme verursachen.
Vielen Dank.
@{
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>
}
wenn Sie Rasierer Syntax verwenden, dann können Sie eine Teilansicht erstellen (die auch eine .cshtml Syntax) stattdessen. Sofern Sie nicht meinen, dass Sie diesen Code in eine separate App portieren möchten, die die WebForms-View-Engine verwendet? – ADyson
Ich möchte diesen Code zu einem vorhandenen dotnetnuke-Modul portieren, das nicht Rasierer verwendet. Es ist eine bestehende .ascx-Seite. – Chris
ist es sogar MVC mit WebForms-Engine oder tatsächliche ältere Webformulare? – ADyson