I have a Razor page with a Partial attached. I would like to disable the Create button. Based on Termination Date. if the Termination Date set to after the present day, hovering over 'Create Side Letter' should disable the button, and add a Bootstrap tooltip. Would anyone be able to offer me some assistance as to how best to do this?
#section scripts {
<script language="javascript" type="text/javascript">
$(function () {
var lastItem = $(".contractSideLetterPanel:last");
var clickableTitle = lastItem.children(".panel-heading:first").find("a");
clickableTitle.click();
});
</script>
}
#section additionalStyles {
#Styles.Render("~/plugins/datatables/media/css/cssDatatables")
}
#section modal {
}
<article class="row">
<h1 class="pageTitle artistHeader fw200 mb20 mt10">#ViewBag.Title</h1>
<div class="col-md-12">
<div class="panel panel-visible" id="sideLettersContainer">
#* Header *#
<div class="panel-heading createContentTitle">
<div class="panel-title createLink">
<a href="#Url.Action("CreateSideLetter", "ClientSetup", new
{
page = Model.PagingInfo.Page,
take = Model.PagingInfo.Take,
sortBy = Model.PagingInfo.SortPropertyName,
sortAsc = Model.PagingInfo.SortAscending
})" data-container="body" data-toggle="tooltip" title="Add Side Letter" id="createSideLetterLink">
<span class="fa fa-file"></span> Create Side Letter
</a>
</div>
</div>
#* body *#
<div class="panel panel-visible tableContainer mbn">
#Html.Partial("_SideLettersList", Model)
</div>
#* Footer *#
<div class="panel-footer text-center">
<a href='#Url.Action("Contracts", "ClientSetup", new
{
page = Model.PagingInfo.Page,
take = Model.PagingInfo.Take,
sortBy = Model.PagingInfo.SortPropertyName,
sortAsc = Model.PagingInfo.SortAscending,
name = Model.SearchModel.Name,
createdby = Model.SearchModel.CreatedBy,
contractType = Model.SearchModel.ContractType,
dateFrom = Model.SearchModel.DateFrom,
dateTo = Model.SearchModel.DateTo
}
)' class="btn btn-primary" id="doneWithSideLettersLink">Done</a>
</div>
</div>
</div>
</article>
Partial
<div class="panel-group accordion accordion-lg mbn" id="sideLetterAccordion">
#* Contract Panel *#
#if (Model.OriginalContract != default(ContractDisplayModel))
{
<div class="panel contractSideLetterPanel mtn">
<div class="panel-heading sideLetterHeading">
<a class="accordion-toggle accordion-icon link-unstyled collapsed" data-toggle="collapse" data-parent="#sideLetterAccordion" href="#accord1">
#GetTitle(Model.OriginalContract.SummaryInfo)
</a>
</div>
<div id="accord1" class="panel-collapse collapse" style="height: 0px;">
<div class="panel-body">
#* START - Summary Information *#
#if (Model.OriginalContract.SummaryInfo.Description != string.Empty)
{
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.Description, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
<span>#Model.OriginalContract.SummaryInfo.Description</span>
</div>
</div>
}
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.ContractType, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
#{
var contractType = Model.OriginalContract.SummaryInfo.ContractType.GetEnumDescription();
}
<span>#contractType</span>
</div>
</div>
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.Currency, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
<span>#Model.OriginalContract.SummaryInfo.Currency</span>
</div>
</div>
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.StartDate, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-4 form-control-static ptn pb5">
<span>#Model.OriginalContract.SummaryInfo.StartDate.ToString("D")</span>
</div>
#if (Model.OriginalContract.SummaryInfo.EndDate != default(DateTime?))
{
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.EndDate, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-4 form-control-static ptn pb5">
<span>#(Model.OriginalContract.SummaryInfo.EndDate != default(DateTime) ? ((DateTime)Model.OriginalContract.SummaryInfo.EndDate).ToString("D") : string.Empty)</span>
</div>
}
</div>
#if (Model.OriginalContract.SummaryInfo.SignedDate != default(DateTime?))
{
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.SignedDate, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
<span>#(Model.OriginalContract.SummaryInfo.SignedDate != default(DateTime) ? ((DateTime)Model.OriginalContract.SummaryInfo.SignedDate).ToString("D") : string.Empty)</span>
</div>
</div>
}
#if (Model.OriginalContract.SummaryInfo.NotificationDate != default(DateTime?))
{
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.NotificationDate, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
<span>#(Model.OriginalContract.SummaryInfo.NotificationDate != default(DateTime) ? ((DateTime)Model.OriginalContract.SummaryInfo.NotificationDate).ToString("D") : string.Empty)</span>
</div>
</div>
}
#if (Model.OriginalContract.SummaryInfo.TerminationDate != default(DateTime?))
{
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.TerminationDate, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
<span>#(Model.OriginalContract.SummaryInfo.TerminationDate != default(DateTime) ? ((DateTime)Model.OriginalContract.SummaryInfo.TerminationDate).ToString("D") : string.Empty)</span>
</div>
</div>
}
#if (Model.OriginalContract.SummaryInfo.PostTermCollectionEndDate != default(DateTime?))
{
<div class="row">
#Html.LabelFor(m => m.OriginalContract.SummaryInfo.PostTermCollectionEndDate, new { #class = "col-sm-2 control-label ptn" })
<div class="col-sm-10 form-control-static ptn pb5">
<span>#(Model.OriginalContract.SummaryInfo.PostTermCollectionEndDate != default(DateTime) ? ((DateTime)Model.OriginalContract.SummaryInfo.PostTermCollectionEndDate).ToString("D") : string.Empty)</span>
</div>
</div>
}
#* END - Summary Information *#
I
One way to achieve this could be to add a boolean property on your ViewModel called something like TerminationDateHasPassed.
public bool TerminationDateHasPassed{ get; set; }
Calculate the value for this new property in code behind. Something like:
TerminationDateHasPassed = TerminationDate < DateTime.Now
In your Partial razor view then you can add the disabled bootsrtap class based on this property to the Create button.
<a href="#Url.Action("CreateSideLetter", "ClientSetup", new
{
page = Model.PagingInfo.Page,
take = Model.PagingInfo.Take,
sortBy = Model.PagingInfo.SortPropertyName,
sortAsc = Model.PagingInfo.SortAscending
})" data-container="body" data-toggle="tooltip"
title="Add Side Letter" id="createSideLetterLink"
class=#(Model.TerminationDateHasPassed ? "disabled": "")>
<span class="fa fa-file"></span> Create Side Letter
</a>
Related
I am trying to create a Bootstrap modal pop up "Ticket successfully created" once you submit a form which posts data through to IActionResult to add to database. However my modal is like transparent with just text and I'm also getting a runtime error of : Obj ref not set to an instance of object
I have a feeling that modal popup is causing the passing of data back to the controller to not work. What is the way around this?
GetTicket view
#model Project.HelpDeskViewModel
<fieldset>
#using (Html.BeginForm())
{
<div class="container">
<div class="form-group">
<div class="row m-4 text-center">
<div class="col-4">
</div>
<div class="col-4">
<h2 style="text-align:center;font-weight:bold">Get A Ticket</h2>
</div>
</div>
</div>
<div class="form-group">
<div class="row m-3">
<div class="col-4" style="text-align:left">
#Html.LabelFor(m => m.category)
</div>
<div class="col-4">
#Html.DropDownListFor(m => m.category, new SelectList(Model.categoryList, "Value", "Text"), "Select category", new { #class = "form-control" })#Html.ValidationMessageFor(model => model.category,
"", new { #class = "text-danger" })
</div>
</div>
</div>
<div class="form-group">
<div class="row m-3">
<div class="col-4" style="text-align:left">
#Html.LabelFor(m => m.ticketDescription)
</div>
<div class="col-4">
#Html.TextAreaFor(m => m.ticketDescription, new { #class = "form-control" })#Html.ValidationMessageFor(model => model.ticketDescription,
"", new { #class = "text-danger" })
</div>
</div>
</div>
<div class="form-group">
#*Modal for ticket creation*#
<div class="modal" id="MyModal" role="dialog">
<div class="modal-dialog">
<div class="model-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4>Ticket Created</h4>
</div>
<div class="modal-body">
<p> Your Helpdesk ticket has been succesfully submitted</p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal"> close</button>
</div>
</div>
</div>
</div>
</div>
<div class="row m-3">
<div class="col-4">
</div>
<div class="col-4" style="text-align:left">
<button type="submit" class="btn btn-primary form-control" data-target="#MyModal" data-toggle="modal">Submit</button>
</div>
</div>
</div>
}
</fieldset>
Controller
[HttpPost]
public IActionResult GetTicket(HelpDeskViewModel h)
{
HelpDeskViewModel sess = new HelpDeskViewModel();
try
{
//session variable passing userID
sess.userID = HttpContext.Session.GetString("userID");
if (!ModelState.IsValid) return View(h);
//h.empID = null; //add ticket record without employeeID - ticket hasn't been assigned yet
h.userID = sess.userID; //add userID from session
_db.helpdesk.Add(h);
_db.SaveChanges();
}
catch (Exception ex)
{
global.gLogger.log.Debug("Debug message: ", ex.Message);
global.gLogger.log.Error(new Exception(), ex.Message);
global.gLogger.log.Error(new Exception(), ex.StackTrace);
global.gLogger.log.Fatal("Fatal message: ", ex.Message); ;
}
return View("GetTicket");
}
You can use ViewBag for open bootstrap modal after successfully return from server to client
Client Side View
#if(ViewBag.SuccessfullyTicketCreated != null)
{
<script>
$('#myModal').modal('show'); // open model by use jQuery
</script>
}
Server side Controller
_db.SaveChanges();
ViewBag.SuccessfullyTicketCreated = true; // create ViewBag after savechange success
I hope help you simple way
Only use of ajax call can solve your problem without creating any further issues. if you are not using jQuery, you can also send ajax call using Javascript using fetch() method.
<form id="form" action="/Controller/GetTicket" method="post">
<div class="container">
<div class="form-group">
<div class="row m-4 text-center">
<div class="col-4">
</div>
<div class="col-4">
<h2 style="text-align:center;font-weight:bold">Get A Ticket</h2>
</div>
</div>
</div>
<div class="form-group">
<div class="row m-3">
<div class="col-4" style="text-align:left">
#Html.LabelFor(m => m.category)
</div>
<div class="col-4">
#Html.DropDownListFor(m => m.category, new SelectList(Model.categoryList, "Value", "Text"), "Select category", new { #class = "form-control" })#Html.ValidationMessageFor(model => model.category,
"", new { #class = "text-danger" })
</div>
</div>
</div>
<div class="form-group">
<div class="row m-3">
<div class="col-4" style="text-align:left">
#Html.LabelFor(m => m.ticketDescription)
</div>
<div class="col-4">
#Html.TextAreaFor(m => m.ticketDescription, new { #class = "form-control" })#Html.ValidationMessageFor(model => model.ticketDescription,
"", new { #class = "text-danger" })
</div>
</div>
</div>
<div class="form-group">
#*Modal for ticket creation*#
<div class="modal" id="MyModal" role="dialog">
<div class="modal-dialog">
<div class="model-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4>Ticket Created</h4>
</div>
<div class="modal-body">
<p> Your Helpdesk ticket has been succesfully submitted</p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal"> close</button>
</div>
</div>
</div>
</div>
</div>
<div class="row m-3">
<div class="col-4">
</div>
<div class="col-4" style="text-align:left">
<button type="submit" class="btn btn-primary form-control" data-target="#MyModal" data-toggle="modal">Submit</button>
</div>
</div>
</div>
</form>
Use Javascript:
<script> function onSubmit(){
$.ajax({
url:'/Controller/GetTicket',
type:'post',
data: $('#form').serialize(),
success: function(){
// code here;}
})
}</script>
My View page, it contains many dynamic controls
I know this question has been asked and answered a dozen of times but none of the solutions help me.
I have a following ViewModel which is consisted of QuestionBatch data model,listResponseTag and a list of listQuestion data model.
View Model
public class VM_Questionaire
{
public QuestionBatch ThequestionBatch { get; set; }
public List<Question> listQuestion { get; set; }
public List<ResponseTag> listResponseTag { get; set; }
}
Controller
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult submit_Questionaire(VM_Questionaire vm_question)
{
if (ModelState.IsValid)
{
Console.Write(Newtonsoft.Json.JsonConvert.SerializeObject(vm_question));
}
return View("Index");
}
View
<pre>
#model Fonz_Survey.Models.VM_Questionaire
#{
ViewBag.Title = "Questionaire";
}
#using (Html.BeginForm("submit_Questionaire", "Questions", FormMethod.Post))
{
#Html.AntiForgeryToken()
<h2>Questionaire</h2>
<div class="card">
<div class="card-header">
<div class="jumbotron-fluid">
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">
<h5 class="text-muted text-monospace">CODE</h5>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 text-danger text-monospace">
#Html.DisplayFor(model => model.ThequestionBatch.Code, new { #class = "text-danger text-monospace" })
#Html.HiddenFor(model => model.ThequestionBatch.Code)
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">
<h5 class="text-muted text-monospace">Question Batch</h5>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 text-primary text-monospace">
#Html.DisplayFor(model => model.ThequestionBatch.BatchName, new { #class = "text-primary text-monospace" })
#Html.HiddenFor(model => model.ThequestionBatch.BatchName)
</div>
<div class="col-lg-3 col-md-6 col-sm-6">
<h5 class="text-muted text-monospace">No of Questions</h5>
</div>
<div class="col-lg-3 col-md-6 col-sm-6">
<label class="text-primary text-monospace">#ViewBag.totalQstns</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">
<h5 class="text-muted text-monospace">Description</h5>
</div>
<div class="col-lg-3 col-md-6 col-sm-6 text-primary text-monospace text-wrap">
#Html.DisplayFor(model => model.ThequestionBatch.Description, new { #class = "text-primary text-monospace text-wrap" })
#Html.HiddenFor(model => model.ThequestionBatch.Description)
</div>
</div>
</div>
</div>
</div>
<div class="card-body">
#{
//int rowIndex = 0;
}
#if (Model != null && Model.listQuestion != null)
{
for(var rowIndex=0; rowIndex< Model.listQuestion.Count; rowIndex++)
//foreach (Question question in Model.listQuestion)
{
// rowIndex++;
<div class="row mb-4">
<div class="col-12">
<div class="card">
<div class="card-header bg-gray text-light">
<div class="d-inline-block">
<label class="text-lg-left font-weight-bold">#rowIndex.</label>
<label class="text-lg-left font-weight-bold">#Model.listQuestion[rowIndex].QuestionEN</label>
<br />
<label class="text-lg-left font-weight-bold">#Model.listQuestion[rowIndex].QuestionAR</label>
</div>
</div>
<div class="card-body font-weight-bolder">
#switch (#Model.listQuestion[rowIndex].QType)
{
case 1:
// to do Text Boxes
<p class="text-info"><u>Please enter your message below;</u></p>
<div class="form-row">
#*<input type="text" placeholder="#question.QuestionEN" name="Q_#question.Id" id="Q_#question.Id" class="form-control" />*#
#Html.EditorFor(model=> #Model.listQuestion[rowIndex].QuestionEN)
</div>
break;
case 2:
// to do Radio
<p class="text-info"><u>Please select any one of the option below;</u></p>
foreach (ChoiceTag ct in Model.listQuestion[rowIndex].ChoiceTags)
{
<div class="form-check">
<label class="form-check-label" for="C_#ct.Id">
<input type="radio" class="form-check-input" id="C_#ct.Id" name="#Model.listQuestion[rowIndex].Id" value="#ct.AnswerEN">#ct.AnswerEN | #ct.AnswerAR
</label>
</div>
}
break;
case 3:
// to do Radio
<p class="text-info"><u>Please select options below;</u></p>
foreach (ChoiceTag ct in Model.listQuestion[rowIndex].ChoiceTags)
{
<div class="form-check">
<label class="form-check-label" for="C_#ct.Id">
<input type="checkbox" class="form-check-input" id="C_#ct.Id" name="#Model.listQuestion[rowIndex].Id" value="#ct.AnswerEN">#ct.AnswerEN | #ct.AnswerAR
</label>
</div>
}
break;
}
</div>
</div>
</div>
</div>
}
<div class="form-group">
<div class="col-12 text-center">
<input type="submit" value="Submit" class="btn btn-success " />
</div>
</div>
}
</div>
<div class="card-footer">
<label class="text-danger">#ViewBag.Message</label>
</div>
</div>
}
</prev>
First object getting value, but the list getting null.
#Html.DisplayFor() will not post values. You need to use #Html.HiddenFor() along with #Html.DisplayFor(). Refer: Html.DisplayFor not posting values to controller in ASP.NET MVC 3
if you're not passing any type of data then make your data as a hidden field and after that you will received your data at your respective controller.
Thanks.
I have been working on this page and after restructuring the HTML, I get following error
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The using block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
Source Error:
Line 43:
Line 44:
Line 45: #using (Html.BeginForm("BookingConfirmation", "UserPortal", FormMethod.Post, new { enctype = "multipart/form-data", #class = "form-horizontal" }))
Line 46: {
Line 47: #Html.HiddenFor(s => s.BookingRequest.BookingInfoId)
Source File: /Views/UserPortal/BookingConfirmation.cshtml Line: 45
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36415
Here's the page code
#using System.Globalization
#using System.Threading
#using Core.Services.Objects
#using NileSat.App_LocalResources
#model NileSat.Models.NileSatViewModel
#{
Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
#*<section id="content_wrapper">
<div class="container">
<div class="row">
<div class="col-xs-12 text-center">
<h1 class="breadTitle">Booking Confirmation</h1>
</div>
</div>
</div>
</section>*#
<section id="content_wrapper">
<header id="topbar">
<div class="topbar-left">
<ol class="breadcrumb">
<li class="crumb-icon">
<a href="#">
<span class="glyphicon glyphicon-home">UserPorta</span>
</a>
</li>
<li class="crumb-trail">
Home
</li>
</ol>
</div>
</header>
<div id="content">
<div class="row">
<div class="col-md-12 col-md-news">
<div class="panel panel-visible">
<div class="panel-heading">
<span class="panel-title">BookingConfirmation</span>
</div>
<div class="panel-body admin-form">
#using (Html.BeginForm("BookingConfirmation", "UserPortal", FormMethod.Post, new { enctype = "multipart/form-data", #class = "form-horizontal" }))
{
#Html.HiddenFor(s => s.BookingRequest.BookingInfoId)
#*<form method="POST" action="#Url.Action("BookingRequest", "UserPortal")">*#
#Html.AntiForgeryToken()
#*<h2>#Resource.ChannelSearch</h2>*#
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.Date</label>
<div class="col-lg-7">
<label class="form-control">#Html.Label(Model.BookingRequest.RequestDT.Value.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture))</label>
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.Time</label>
<div class="col-lg-7">
<label class="form-control">#Html.Label(Model.BookingRequest.RequestDT.Value.ToString("HH:mm:ss", CultureInfo.InvariantCulture))</label>
#Html.HiddenFor(s => s.BookingRequest.RequestDT)
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.RequestNumber</label>
<div class="col-lg-7">
<label class="form-control">#Html.Label(Model.BookingRequest.RequestNum.ToString())</label>
#Html.HiddenFor(s => s.BookingRequest.RequestNum)
</div>
</div>
#*<div class="form-group col-lg-6">
<label>#Resource.RequestNumber</label>
#(Html.LabelFor(cs => cs.BookingRequest.RequestNum))
</div>*#
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.CompanyName</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.CompanyName, new { disabled = "disabled", #class = "form-control" }))
#*#Html.ValidationMessageFor(model => model.BookingRequest.CompanyName, null, new { #class = "contactError" })*#
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.ChannelName</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.ChannelName, new { disabled = "disabled", #class = "form-control" }))
#*#Html.ValidationMessageFor(model => model.BookingRequest.ChannelName, null, new { #class = "contactError" })*#
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.AuthorPerson</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.AuthorName, new { disabled = "disabled", #class = "form-control" }))
#*#Html.ValidationMessageFor(model => model.BookingRequest.AuthorName, null, new { #class = "contactError" })*#
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.ContactEmail</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.ContactEmail, new { disabled = "disabled", #class = "form-control" }))
#*#Html.ValidationMessageFor(model => model.BookingRequest.ContactEmail, null, new { #class = "contactError" })*#
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.ContactPhone</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.ContactPhone, new { disabled = "disabled" }))
#*#Html.ValidationMessageFor(model => model.BookingRequest.ContactPhone, null, new { #class = "contactError" })*#
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.ContactFax</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.ContactFax, new { disabled = "disabled", #class = "form-control" }))
#*#Html.ValidationMessageFor(model => model.BookingRequest.ContactFax, null, new { #class = "contactError" })*#
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">#Resource.ServiceName</label>
<div class="col-lg-7">
#(Html.DropDownListFor(cs => cs.BookingRequest.BookingServiceId, //"BookingServiceId",
new SelectList(Model.BookingServiceTypeViewModels, "Id", "ServiceName"
, Resource.ServiceName), new { disabled = "disabled" }))#*,Resource.All, new {#title = Resource.ServiceName}*#
, new { #class = "form-control" })
</div>
</div>
<div class="form-cn form-hotel tab-pane active in" id="form-hotel">
<div id="TADiv" style="display: none">
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Satellite Name</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.SatelliteName, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Orbital Position</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.OrbitalPosition, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">D/L Freq</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.DLFreq, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">
Polarization
</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.Polarization, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">S.R</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.SR, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">FEC</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.FEC, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">DVBS</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.DVBS, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">DVB S2</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.DVBS2, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Date</label>
<div class="col-lg-7">
#*#(Html.Kendo().DatePickerFor(cs => cs.BookingRequest.BookingDetails.Date))*#
<label class="form-control">#(Html.Kendo().DatePickerFor(m => m.BookingRequest.BookingDetails.Date).Enable(false))</label>
#*#Html.HiddenFor(s => s.BookingRequest.BookingDetails.Date)*#
</div>
<div>
#*<button type="submit" class="button btn-primary" id="btn_AddTime" name="submit" value="AddNewEntry">Add Time</button>*#
#Html.Partial("_RequestTimes", Model)
</div>
<div class="form-group col-lg-6" id="Bw_Div">
<label class="col-lg-4 control-label">BW</label>
<div class="col-lg-7">
#(Html.DropDownListFor(cs => cs.BookingRequest.BookingDetails.BWRequiredId,
new SelectList(Model.BookingInfoBWViewModels, "Id", "BW"), "None", new { #title = "BW", disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6" id="Event_Div">
<label class="col-lg-4 control-label">Event/Conf Name</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.EventConfName, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6" id="src_Div">
<label class="col-lg-4 control-label">Source</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.Source, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6" id="Dest_Div">
<label class="col-lg-4 control-label">Destination</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.Destination, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
#*<div class="form-group col-lg-6">
<label>Destination</label>
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.Destination))
</div>*#
<div id="MergeDIV" style="display: none">
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Channel Name</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.ChannelName, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
</div>
<div id="SNGDiv" style="display: none">
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Station Id</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.StationId, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Station Contact Name</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.StationContactName, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Station Contact Phone</label>
<div class="col-lg-7">
#(Html.TextBoxFor(cs => cs.BookingRequest.BookingDetails.StationContactPhone, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
</div>
<div class="form-group col-lg-6" id="encryption_Div">
<label class="col-lg-4 control-label">Encryption</label>
<div class="col-lg-7">
#(Html.CheckBoxFor(cs => cs.BookingRequest.BookingDetails.IsEncrypted, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Other Details</label>
<div class="col-lg-7">
#(Html.TextAreaFor(cs => cs.BookingRequest.BookingDetails.OtherDetails, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
<div class="form-group col-lg-6" id="IsAgreed_Div">
<label class="col-lg-4 control-label">Agreement</label>
<div class="col-lg-7">
#(Html.CheckBoxFor(cs => cs.BookingRequest.BookingDetails.isAgreed, new { disabled = "disabled", #class = "form-control" }))
</div>
</div>
</div>
<div class="form-group col-lg-12">
<div class="col-lg-4">
</div>
<div class="col-lg-7">
<input type="submit" value="Confirm and Send E-mail" name="submit" class="btn btn-hover btn-danger btn-block pull-right" />
</div>
</div>
}
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script>
$('#BookingRequest_BookingServiceId').change(function () {
debugger;
// alert('hello');
var SelectedValue = $(this).val();
showHideDivs(SelectedValue);
});
$(function () {
debugger;
var SelectedValue = $('#BookingRequest_BookingServiceId').val();
showHideDivs(SelectedValue);
});
function showHideDivs(SelectedValue) {
if (SelectedValue == 1) {//feed
$('#TADiv').hide();
$('#btn_AddTime').show();
$('#Bw_Div').show();
$('#Event_Div').show();
$('#src_Div').show();
$('#Dest_Div').show();
$('#MergeDIV').hide();
$('#SNGDiv').hide();
$('#encryption_Div').show();
$('#IsAgreed_Div').show();
}
else if (SelectedValue == 2) {// fiber
$('#TADiv').hide();
$('#btn_AddTime').show();
$('#Bw_Div').hide();
$('#Event_Div').show();
$('#src_Div').show();
$('#Dest_Div').show();
$('#MergeDIV').hide();
$('#SNGDiv').hide();
$('#encryption_Div').hide();
$('#IsAgreed_Div').show();
}
else if (SelectedValue == 3) {//T.A
$('#TADiv').show();
$('#btn_AddTime').show();
$('#Bw_Div').hide();
$('#Event_Div').hide();
$('#src_Div').hide();
$('#Dest_Div').hide();
$('#MergeDIV').hide();
$('#SNGDiv').hide();
$('#encryption_Div').hide();
$('#IsAgreed_Div').show();
}
else if (SelectedValue == 4) { // SNG
$('#TADiv').hide();
$('#btn_AddTime').show();
$('#Bw_Div').show();
$('#Event_Div').show();
$('#src_Div').show();
$('#Dest_Div').show();
$('#MergeDIV').hide();
$('#SNGDiv').hide();
$('#encryption_Div').hide();
$('#IsAgreed_Div').show();
}
else //(SelectedValue == 1)
{
$('#TADiv').hide();
$('#btn_AddTime').hide();
$('#Bw_Div').hide();
$('#Event_Div').show();
$('#src_Div').hide();
$('#Dest_Div').hide();
$('#MergeDIV').show();
$('#SNGDiv').hide();
$('#encryption_Div').hide();
$('#IsAgreed_Div').show();
}
}
</script>
Can anyone please help find out what I have missed. It could be a div not closed, but I cant find it.
<div class="panel-body admin-form">
#using (Html.BeginForm("BookingConfirmation", "UserPortal", FormMethod.Post, new {...}))
{
<div class="form-group col-lg-6">
<label class="col-lg-4 control-label">Date</label>
<!--other code-->
<!--Not closing div here-->
}
</div><!--Date div is mistakenly matching this close tag and leaving close brace inside-->
I am passing a list to a view to display in a grid. Underneath the grid I have a form to allow the user to submit new values into the grid. When the controller is called the model always seems to be empty, I am not sure what I am doing wrong or if I should be doing this in a different way entirely.
The relavent parts of the view are as follows
#model IList<PSIApp.Models.PSM_StationTimetableView>
#using (Html.BeginForm())
{
<div class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#collapse3">Hourly Update ▼</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse in" style="width:100%; margin-left:0%; margin-right:50px;">
<div class="mainformCollapse" style="width:100%; margin-left:0%; margin-right:50px;">
<p class="group-header">Hourly Update</p>
<div class="form-group row">
<label for="example-text-input" class="col-xs-3 col-form-label" id="formLabelId">BP Issued</label>
<div class="col-xs-3">
#Html.MyTextBoxFor(p => p[0].PSM_StationBPData.BPIssued, new { #class = "generalformbox" }, false)
</div>
<label for="example-text-input" class="col-xs-3 col-form-label " id="formLabelId">BP Cancelled/Spoilt</label>
<div class="col-xs-3">
#Html.TextBoxFor(p => p[0].PSM_StationBPData.BPSpoilt, new { #class = "generalformbox" })
</div>
</div>
<div class="form-group row">
<label for="example-text-input" class="col-xs-3 col-form-label" id="formLabelId">AV Issued</label>
<div class="col-xs-3">
#Html.TextBoxFor(p => p[0].PSM_StationBPData.PostalReceived, new { #class = "generalformbox" })
</div>
<label for="example-text-input" class="col-xs-3 col-form-label" id="formLabelId">Tendered Issued</label>
<div class="col-xs-3">
#Html.TextBoxFor(p => p[0].PSM_StationBPData.BPTendered, new { #class = "generalformbox" })
</div>
</div>
<input type="submit" value="Submit Hourly Update" class="standardsubmitbt" />
</div>
</div>
</div>
</div>
}
Controller
public ActionResult POControl(Models.PSM_StationBPData model)
{
return RedirectToAction("POControl");
}
You are sending an IList of PSM_StationTimetableView, but you are expecting a PSM_StationBPData on the controller.
I can add a create partial view within a modal bootstrap so that it can add value in the table with a edit view of the field value ?
My create partial view
#model MVCLayout.Models.Table2
<p>
#using (Html.BeginForm())
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<div class="form-group">
#Html.Label("Cargo: ", new { style = "width:160px" })
#Html.TextBoxFor(model => model.ID, new { style = "width:200px" })
</div>
<br/>
<div class="form-group">
#Html.Label("Percentual: ", new { style = "width:160px" })
#Html.TextBoxFor(model => model.Name, new { style = "width:200px" })
</div>
<br/>
<div class="form-group">
#Html.Label("Serviço: ", new { style = "width:160px" })
#Html.TextBoxFor(model => model.Work, new { style = "width:200px" })
</div>
<br/>
<p>
<input type="submit" value="Save" />
</p>
}
</p>
My Edit View
<html>
<body>
#model MVCLayout.Models.Table1
#{
ViewBag.Title = "Edit";
}
<div id="signup">
<div class="rontainer">
<div class="header">
<div id="dock">
<br>
#using (Html.BeginForm("Edit", "AdmServicos", FormMethod.Post, new { #class = "form-inline" }))
{
#Html.AntiForgeryToken()
<fieldset>
<legend>Editar Servios</legend>
<br>
<div class="form-group">
#Html.Label("Código:", new { style = "width:160px" })
#Html.TextBoxFor(model => model.ID, new { style = "width:55px", #readonly = "readonly" })
<div class="form-group">
#Html.Label("Descrição: ", new { style = "width:160px" })
#Html.TextBoxFor(model => model.Descricao, new { style = "width:550px", #readonly = "readonly" })
</div>
</div>
<br />
<br /><br />
<p>
<input type="submit" value="Salvar" />
</p>
</fieldset>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
#{
Html.RenderPartial("CreateTable2", Model.ID);
}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
}
</div>
</div>
</div>
</body>
</html>
Can I do this with a partial view or the best way to do this?
create a property of Table2 type in your Table1 Model like below :
public class Table1
{
public Table2 table2 {get; set;}
//other properties of Table1 Model
}
Now in your Edit View:
<div class="modal-body">
#{
Html.RenderPartial("CreateTable2", Model.table2);
}
</div>
Now in your Action of the Controller :
public ActionResult Edit(Table1 model)
{
var editPartialViewData = model.table2;
// Do whatever you want to do with this data
}