c# - Submit button is not working in asp.net mvc -
i have model:
public class formcreatemodel { public formmodel forminfo { get; set; } public fieldmodel fieldinfo { get; set; } public institutionmodel selectedinst { get; set; } public formtypemodel selectedformtype { get; set; } public categorymodel categoryinfo { get; set; } public list<institutionmodel> institutions { get; set; } public list<formtypemodel> formtypes { get; set; } }
and i've created typed view model:
@using (html.beginform()) { <p> @html.labelfor(lbl =>lbl.selectedinst.institution_name, "institution name :", new { @class="lblname"}) @html.dropdownlistfor(drpdown => drpdown.selectedinst.institution_name, new selectlist(model.institutions.select(inst => inst.institution_name)),"-- select institution--", new { @class ="txtformtext"}) </p> <p> @html.labelfor(lbl => lbl.forminfo.form_name, "form name", new {@class ="lblname"}) @html.textboxfor(txtbox => txtbox.forminfo.form_name, new { @class ="txtformtext"}) </p> <p> @html.labelfor(lbl => lbl.forminfo.form_desc, "form description", new {@class ="lblname" }) @html.textareafor(txtbox => txtbox.forminfo.form_desc,4,5,new { @class ="txtformtext"}) </p> <p> @html.labelfor(lbl => lbl.forminfo.activationdate, "form activation date", new {@class ="lblname :" }) @html.dropdownlistfor(drpdown => drpdown.forminfo.activationdate.day, new selectlist(enumerable.range(1,31)),"day", new {@class="slctdate"}) @html.dropdownlistfor(drpdown => drpdown.forminfo.activationdate.month, new selectlist(enumerable.range(1,12)),"month", new {@class="slctdate"}) @html.dropdownlistfor(drpdown => drpdown.forminfo.activationdate.year, new selectlist(enumerable.range(datetime.now.year, datetime.now.year + 4)),"year", new {@class="slctdate"}) </p> <p> @html.labelfor(lbl => lbl.forminfo.expiredate, "form expiration date", new {@class ="lblname" }) @html.dropdownlistfor(drpdown => drpdown.forminfo.expiredate.day, new selectlist(enumerable.range(1,31)),"day", new {@class="slctdate"}) @html.dropdownlistfor(drpdown => drpdown.forminfo.expiredate.month, new selectlist(enumerable.range(1,12)),"month", new {@class="slctdate"}) @html.dropdownlistfor(drpdown => drpdown.forminfo.expiredate.year, new selectlist(enumerable.range(datetime.now.year, datetime.now.year + 4)),"year", new {@class="slctdate"}) </p> <p> @html.labelfor(lbl => lbl.forminfo.logo, "form description", new {@class ="lblname" }) @html.textboxfor(txtbox => txtbox.forminfo.logo,new { @class ="txtformtext"}) </p> <p> @html.labelfor(lbl => lbl.selectedformtype.formtypename, "form type", new {@class ="lblname" }) @html.dropdownlistfor(drpdown => drpdown.selectedformtype.formtypename, new selectlist(model.formtypes.select(m => m.formtypename)), "--- select form type---", new {@class="txtformtext" }) </p> <input id="btnsubmit" type="button" value="submit" /> }
my controller:
public actionresult createnewform(formcreatemodel newform) { institutionmanagement im = new institutionmanagement(); newform.institutions = im.getinstitution(); formmanagement fm = new formmanagement(); newform.formtypes = fm.getformtype(); return view("createnewform", newform); }
when submitting button newform remains empty.. debug , found submit button not triggering or sending values newform. few days in mvc please help
change
<input id="btnsubmit" type="button" value="submit" />
to
<input id="btnsubmit" type="submit" value="submit" />
you should use submit
instead of button
input element type
attribute
Comments
Post a Comment