Note that there are some explanatory texts on larger screens.

plurals
  1. POOn Submit, action not going to controller in MVC3
    primarykey
    data
    text
    <p>If I am clicking on submit button in cshtml file then action is not going to controller. I have already created the GET method for that. But posting only post method. Get is working fine..</p> <p><strong>MODEL</strong> </p> <pre><code>public class ABCModel { public int ABCQueryId { get; set; } public int UserId { get; set; } [Required] [StringLength(100, ErrorMessage = "Query cannot be more than 100 characters long.")] [Display(Name = "Query Title*")] public string QueryTitle { get; set; } [Display(Name = "Specific Notes *")] public string SpecificNotes { get; set; } public DateTime QueryDate; public string Status { get; set; } public string SupportDocument { get; set; } } </code></pre> <p><strong>Cshtml Page</strong></p> <pre><code>@using (Ajax.BeginForm("ABC", "Queries", null, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "content", LoadingElementId = "mask" }, new { enctype = "multipart/form-data", id = "intake_form", @class = "inline-form clear_both" })) { &lt;div id="intake_sheet_1" style="visibility: visible"&gt; @Html.HiddenFor(model =&gt; model.ABC.ABCQueryId) @{ String errorMessage = ""; if (Session["errorMessage"] != null) { errorMessage = Session["errorMessage"].ToString(); } if (!String.IsNullOrEmpty(errorMessage)) { &lt;span class="pendingtxt" style="color:red;font-size:13px;"&gt;@errorMessage&lt;/span&gt; } } &lt;div class="form_row"&gt; &lt;div class="form_col1"&gt; &lt;label class="QueryPageHeadings"&gt; Title*&lt;/label&gt; &lt;/div&gt; &lt;div class="form_col2" style="z-index: 24; position: relative;" id="queryTitle_div"&gt; @Html.TextBoxFor(m =&gt; m.ABC.QueryTitle, new { @class = "text QueryFormTextBox" }) &lt;br /&gt; &lt;div style="float: left"&gt; @Html.ValidationMessageFor(m =&gt; m.ABC.QueryTitle) &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form_row"&gt; &lt;div class="form_col1"&gt; &lt;label class="QueryPageHeadings"&gt; Specific Notes&lt;/label&gt; &lt;/div&gt; &lt;div class="form_col2" style="z-index: 21; position: relative;" id="specific_note_div"&gt; @Html.TextAreaFor(m =&gt; m.ABC.SpecificNotes, new { @class = "text QueryFormTextBox", style = "resize:none;height:160px;" }) &lt;br /&gt; &lt;div style="float: left"&gt;@Html.ValidationMessageFor(m =&gt; m.ABC.SpecificNotes) &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form_row"&gt; &lt;div class="form_col1"&gt; &lt;label class="QueryPageHeadings"&gt; Supporting Document &lt;/label&gt; &lt;/div&gt; &lt;div class="form_col2"&gt; &lt;div style="width:100%;float:left;"&gt; @Html.TextBoxFor(m =&gt; m.ABC.SupportDocument, new { @Id = "lblFileName", @readonly = "readonly" }) &lt;/div&gt; &lt;div style="width:100%;float:left;"&gt; &lt;button id='btnUploadPopup' type="button" style="float:left;" onclick="javascript:OpenFileUpload();"&gt; Upload Files&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form_row form_footer"&gt; &lt;p class="indent"&gt; &lt;input class="primary button float_right" value="Submit" type="submit" name="button" /&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Controller</strong></p> <pre><code> [AcceptVerbs(HttpVerbs.Post)] public ActionResult ABC(ABCViewModel model, string button) { QURManager manager = new QURManager(); if (Session["userDetails"] != null) { manager = new QURManager((RegModel)Session["userDetails"]); } String errorMessage = ""; if (String.IsNullOrEmpty(errorMessage)) { errorMessage = errorMessage + " Fields can not be empty."; } if (!String.IsNullOrEmpty(errorMessage)) { Session["errorMessage"] = errorMessage; IABC data = new ABCViewModel(); data.ABC.QueryTitle = model.ABC.QueryTitle; data.ABC.SpecificNotes = model.ABC.SpecificNotes; data.ABC.SupportDocument = model.ABC.SupportDocument; TempData["isEdit"] = false; return View("ABC", data); } else { Session["errorMessage"] = ""; Session.Remove("errorMessage"); } Session["fileName"] = null; AssignSession.UpdateRegisterUserSession(); return View(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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