Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload