I have an MVC3 Razor form in index.cshtml using HtmlHelper
. It works, but I want to replace it with Ajax form using AjaxHelper
(note: I am still not familiar to Ajax/jQuery). It fails. My questions:
- What's wrong with my code?
- Are there any good websites that explain this kind of transformation?
- If one transforms a view to Ajax processing, is it necessary to change the controller as well?
Here's my index.cshtml file. My trial with Ajax is commented out below the MVC3 form.
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
@using ( Html.BeginForm("UploadFile", "Home", FormMethod.Post, new
{
enctype = "multipart/form-data"
}) )
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Select a file</legend>
<input type="file" id="fileupload" name="fileuploadname" />
<p>
<input type="submit" value="Upload" id="upload" onclick="javascript:document.getElementById('upload').disabled=true; document.getElementById('upload').value='Uploading...'" />
</p>
</fieldset>
}
@* @using ( Ajax.BeginForm("UploadFile", "Home",
new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST"
}) )
{
<input type="file" id="fileupload" name="fileuploadname" />
<p>
<input type="submit" value="Upload" id="upload" onclick="javascript:document.getElementById('upload').disabled=true; document.getElementById('upload').value='Uploading...'" />
</p>
}
*@
Thx in advance.