asp.net mvc 5.1 - My Model Textbox is not Displayed properly -


user id displayed answer enter image description herei working on mvc 5 project in each , every page getting textbox model in page not able textbox model properly....

i explain clearly.....

my view page:

<div class="container">     <fieldset>         <legend>leave application</legend>         @using (html.beginform(new { @class = "form-horizontal" }))         {             @html.antiforgerytoken()             @html.validationsummary("", new { @style = "color:red" })             @html.raw(tempdata["success"])              @* user id *@             <div class="form-group">                 @html.labelfor(m => m.userid,new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.textboxfor(m => m.userid, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                     @html.validationmessagefor(m => m.userid, "", new { @style = "color:red" })                 </div>             </div>              @* user name *@             <div class="form-group">                 @html.labelfor(m => m.username, new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.textboxfor(m => m.username, new { placeholder = "enter username", @readonly = "readonly", @class = "from-control" })                     @html.validationmessagefor(m => m.username, "", new { @style = "color:red" })                 </div>             </div>              @* leaves required *@             <div class="form-group">                 @html.labelfor(m => m.leavesavailed, new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.textboxfor(m => m.leavesavailed, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                     @html.validationmessagefor(m => m.leavesavailed, "", new { @style = "color:red" })                 </div>             </div>              @* nature of leave *@             <div class="form-group">                 @html.labelfor(m => m.natureofleave, new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.dropdownlistfor(m => m.natureofleave, viewbag.assignroleviewmodel ienumerable<selectlistitem>, "-select-")                     @html.validationmessagefor(m => m.natureofleave, "", new { @style = "color:red" })                 </div>             </div>              @* start date *@             <div class="form-group">                 @html.labelfor(m => m.startdate, new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.textboxfor(m => m.startdate, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                     @html.validationmessagefor(m => m.startdate, "", new { @style = "color:red" })                 </div>             </div>              @* end date *@             <div class="form-group">                 @html.labelfor(m => m.enddate, new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.textboxfor(m => m.enddate, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                     @html.validationmessagefor(m => m.enddate, "", new { @style = "color:red" })                 </div>             </div>              @* reason *@             <div class="form-group">                 @html.labelfor(m => m.reason, new { @class = "col-md-3 control-label" })                 <div class="col-md-6">                     @html.textboxfor(m => m.reason, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                     @html.validationmessagefor(m => m.reason, "", new { @style = "color:red" })                 </div>             </div>             <ul>                 @* userid *@                 <li>                     @html.labelfor(m => m.userid)                     @html.textboxfor(m => m.userid, new { placeholder = "enter userid", @readonly = "readonly" })                     @html.validationmessagefor(m => m.userid, "", new { @style = "color:red" })                 </li>                 @* username *@                 <li>                     @html.labelfor(m => m.username)                     @html.textboxfor(m => m.username, new { placeholder = "enter username", @readonly = "readonly" })                     @html.validationmessagefor(m => m.username, "", new { @style = "color:red" })                 </li>                 @* leaves availed *@                 <li>                     @html.labelfor(m => m.leavesavailed)                     @html.textboxfor(m => m.leavesavailed, new { placeholder = "number of days required" })                     @html.validationmessagefor(m => m.leavesavailed, "", new { @style = "color:red" })                 </li>                 @* type of leave *@                 <li>                     @html.labelfor(m => m.natureofleave)                     @html.dropdownlistfor(m => m.natureofleave, viewbag.assignroleviewmodel ienumerable<selectlistitem>, "-select-")                     @html.validationmessagefor(m => m.natureofleave, "", new { @style = "color:red" })                 </li>                 @* start date *@                 <li>                     @html.labelfor(m => m.startdate)                     @html.textboxfor(m => m.startdate, new { placeholder = "enter startdate" })                     @html.validationmessagefor(m => m.startdate, "", new { @style = "color:red" })                 </li>                 @* end date *@                 <li>                     @html.labelfor(m => m.enddate)                     @html.textboxfor(m => m.enddate, new { placeholder = "enter enddate", @readonly = "readonly" })                     @html.validationmessagefor(m => m.enddate)                 </li>                 @* reason *@                 <li>                     @html.labelfor(m => m.reason)                     @html.textboxfor(m => m.reason, new { placeholder = "enter reason leave" })                     @html.validationmessagefor(m => m.reason, "", new { @style = "color:red" })                 </li>             </ul>             <div class="btn-toolbar">                 <button type="submit" id="btnleaves" name="btnleaves" class="btn btn-success btn-pressure">apply</button>                 <button type="button" id="btncancel" name="btncancel" class="btn btn-primary btn-pressure">cancel</button>             </div>         }     </fieldset> </div> 

my model:

public class employeeleave     {         //[display(name = "user id")]         public int userid { get; set; }          [display(name = "leave id")]         public int natureid { get; set; }          [display(name = "user name")]         public string username { get; set; }          [display(name = "type of leave")]         public list<selectlistitem> natureofleave { get; set; }          //[datatype(datatype.datetime)]         //[displayformat(applyformatineditmode = true, dataformatstring = "{0:dd-mm-yy}")]         public datetime startdate { get; set; }          //[datatype(datatype.datetime)]         //[displayformat(applyformatineditmode = true, dataformatstring = "{0:dd-mm-yy}")]         public datetime enddate { get; set; }          [required]         [display(name = "reason")]         public string reason { get; set; }          [required]         [display(name = "no. of leaves required")]         public int leavesavailed { get; set; }          //public int leavesremained { get; set; }          //public int totalleaves { get; set; }     } 

my controller:

[httpget]         [allowanonymous]         public actionresult leave()         {             employeeleave objempleave = new employeeleave();             objempleave.userid = convert.toint32(session["userid"]);             objempleave.username = convert.tostring(session["name"]);             objempleave.natureofleave = binddatafromdatabasetoleave();             return view(objempleave);         } [httppost]         [allowanonymous]         [validateantiforgerytoken]         public actionresult leave(employeeleave objempleave)         {             objempleave.natureofleave = binddatafromdatabasetoleave();             var selectitem = objempleave.natureofleave.find(p => p.value == objempleave.natureid.tostring());              if (selectitem != null)             {                 selectitem.selected = true;                 viewbag.message = "natureofleave " + selectitem.text;             }             if (string.isnullorempty(objempleave.startdate.tostring()))             {                 modelstate.addmodelerror("error", "please provide start date");             }             else if (string.isnullorempty(objempleave.enddate.tostring()))             {                 modelstate.addmodelerror("error", "please provide end date");             }             else if (string.isnullorempty(objempleave.natureofleave.tostring()))             {                 modelstate.addmodelerror("error", "select one");             }             else if (string.isnullorempty(objempleave.reason))             {                 modelstate.addmodelerror("error", "reason leave");             }              else             {                 //objempleave.userid = convert.toint32(session["userid"]);                 //objempleave.username = convert.tostring(session["name"]);                 int leaveid = objiaccountdata.insertleave(objempleave.userid);                 int numberofleavesavailed = objempleave.leavesavailed;              }             return view(objempleave);         } 

finally output is: user id

but require textbox beside userid label here user id label remaining pages works fine me in advance if can me alot.... struggling 2 days

use please:

    <div class="container"> <fieldset>     <legend>leave application</legend>     @using (html.beginform(new { @class = "form-horizontal" }))     {         @html.antiforgerytoken()         @html.validationsummary("", new { @style = "color:red" })         @html.raw(tempdata["success"])          @* user id *@         <div class="form-group">             @html.labelfor(m => m.userid,new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.textboxfor(m => m.userid, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                 @html.validationmessagefor(m => m.userid, "", new { @style = "color:red" })             </div>         </div>          @* user name *@         <div class="form-group">             @html.labelfor(m => m.username, new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.textboxfor(m => m.username, new { placeholder = "enter username", @readonly = "readonly", @class = "from-control" })                 @html.validationmessagefor(m => m.username, "", new { @style = "color:red" })             </div>         </div>          @* leaves required *@         <div class="form-group">             @html.labelfor(m => m.leavesavailed, new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.textboxfor(m => m.leavesavailed, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                 @html.validationmessagefor(m => m.leavesavailed, "", new { @style = "color:red" })             </div>         </div>          @* nature of leave *@         <div class="form-group">             @html.labelfor(m => m.natureofleave, new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.dropdownlistfor(m => m.natureofleave, viewbag.assignroleviewmodel ienumerable<selectlistitem>, "-select-")                 @html.validationmessagefor(m => m.natureofleave, "", new { @style = "color:red" })             </div>         </div>          @* start date *@         <div class="form-group">             @html.labelfor(m => m.startdate, new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.textboxfor(m => m.startdate, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                 @html.validationmessagefor(m => m.startdate, "", new { @style = "color:red" })             </div>         </div>          @* end date *@         <div class="form-group">             @html.labelfor(m => m.enddate, new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.textboxfor(m => m.enddate, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                 @html.validationmessagefor(m => m.enddate, "", new { @style = "color:red" })             </div>         </div>          @* reason *@         <div class="form-group">             @html.labelfor(m => m.reason, new { @class = "col-md-3 control-label" })             <div class="col-md-6">                 @html.textboxfor(m => m.reason, new { placeholder = "enter userid", @readonly = "readonly", @class = "from-control" })                 @html.validationmessagefor(m => m.reason, "", new { @style = "color:red" })             </div>         </div>         <div class="btn-toolbar">             <button type="submit" id="btnleaves" name="btnleaves" class="btn btn-success btn-pressure">apply</button>             <button type="button" id="btncancel" name="btncancel" class="btn btn-primary btn-pressure">cancel</button>         </div>     } </fieldset> 

with css:

    form ul{ background: #eee; margin: 0.1em; border: 2px solid red; }      form li{ border: 2px solid #eee; border-bottom: 0; margin-bottom: 0;      position: relative; }      form li:first-child { border-top: 0; }      form li:nth-child(2) { border: 2px solid #eee; }     label, input, textarea { display: block; border: 0; }      input, textarea { width: 100%; height: 100%; padding: 2.25em 1.2em 1em;      outline: 0; border: 2px solid #eee; }      label { font-size: 1em; position: absolute; top: 1em; left: 1.15em;      color: #000000; opacity: 1; } 

remove ul element , content , make sure text not white. if text white , background white ofcourse not seen.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -