Ramco Ramco

Ramco Ramco

  • 443
  • 3.4k
  • 526.8k

Default Value in Modal Popup

May 31 2021 12:32 PM
Hi
 
   I want whem Add Modal Popup opens ISActive value by default should be Y & disabled.
 
**********************
public class Location
{
private string _isactive = "Y";
[Key]
[Display(Name = "Id")]
public string Id { get; set; }
[DataType(DataType.Text)]
[RegularExpression(@"^[a-zA-Z'.\s]{1,25}$", ErrorMessage = "Special Characters not allowed")]
[Required(ErrorMessage = "Please enter Location"), MaxLength(25)]
[Display(Name = "Description")]
public string Description { get; set; }
[Display(Name = "Active")]
public string IsActive
{
get { return _isactive; }
set { _isactive = value; }
}
}
 
******************************************
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add New Location</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-3" for="Id">Location Id</label>
<div class="col-sm-2">
<input type="text" class="form-control form-control-sm" id="txtId" placeholder="Id">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="Description">Location Name</label>
<div class="col-sm-9">
<input type="text" class="form-control form-control-sm" id="txtDescription" placeholder="Description">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3" for="IsActive">Active</label>
<div class="col-sm-2">
<input type="text" class="form-control form-control-sm" id="txtIsActive" placeholder="Active">
</div>
</div>
</div>
</div>
<div class="modal-footer">
@*<button type="button" class="btn btn-primary" id="btnAdd" onclick="return Add();"><span class="glyphicon glyphicon-ok"></span>Save</button>*@
<button type="button" class="btn btn-primary" id="btnAdd" onclick="return Add();">Save</button>
<button type="button" class="btn btn-primary" id="btnUpdate" style="display:none;" onclick="Update();">Update</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
 
 
 
Thanks 

Answers (3)