how to use modal popup in my partial view in mvc
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
i want to load Modal as popup on button click through which user can save info in the database problem i am facing is my partial view which consist of that button has
IEnumerable modal and the modal form consist of normal model like @model Key so one model overlapping other and it is not working.
Here is my view
@model IEnumerable<RoomTypeView>
<div class="card border rounded DropShadow" style="border-top-right-radius:50%;">
<div class="card-body">
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.RoomNo)
@Html.DisplayFor(modelItem => item.GuestName)
@($"{item.CheckIn:dd/MMM} - {item.CheckOut:dd/MMM}")
@Html.DisplayFor(modelItem => item.Status)
<div class="form-inline">
<button type="button" class="btn btn-default modalkey" data-toggle="modal" data-target="#myModal"><i class="fas fa-key" style="@(item.Status.HasFlag(EnumHkStatus.Repair) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-broom" style="@(item.Status.HasFlag(EnumHkStatus.Cleaning) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-clipboard-list" style="@(item.Status.HasFlag(EnumHkStatus.InventoryCheck) ? "color:red;": "")"></i></button>
</div>
@Html.DisplayFor(modelItem => item.Comments)
}
</div>
</div>
@model KeyLog
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Key Log</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@if (Model?.KeyLogId > 0)
{
@Html.HiddenFor(model => model.KeyLogId)
}
<div class="form-group">
@Html.LabelFor(model => model.UserId, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UserId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NameOfPerson, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.NameOfPerson, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.NameOfPerson, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PurposeForGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.PurposeForGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.PurposeForGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyReturned, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyReturned, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyReturned, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
is there another way to achieve this with placing that modal into another view
javascript c# asp.net-mvc razor bootstrap-modal
add a comment |
i want to load Modal as popup on button click through which user can save info in the database problem i am facing is my partial view which consist of that button has
IEnumerable modal and the modal form consist of normal model like @model Key so one model overlapping other and it is not working.
Here is my view
@model IEnumerable<RoomTypeView>
<div class="card border rounded DropShadow" style="border-top-right-radius:50%;">
<div class="card-body">
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.RoomNo)
@Html.DisplayFor(modelItem => item.GuestName)
@($"{item.CheckIn:dd/MMM} - {item.CheckOut:dd/MMM}")
@Html.DisplayFor(modelItem => item.Status)
<div class="form-inline">
<button type="button" class="btn btn-default modalkey" data-toggle="modal" data-target="#myModal"><i class="fas fa-key" style="@(item.Status.HasFlag(EnumHkStatus.Repair) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-broom" style="@(item.Status.HasFlag(EnumHkStatus.Cleaning) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-clipboard-list" style="@(item.Status.HasFlag(EnumHkStatus.InventoryCheck) ? "color:red;": "")"></i></button>
</div>
@Html.DisplayFor(modelItem => item.Comments)
}
</div>
</div>
@model KeyLog
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Key Log</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@if (Model?.KeyLogId > 0)
{
@Html.HiddenFor(model => model.KeyLogId)
}
<div class="form-group">
@Html.LabelFor(model => model.UserId, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UserId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NameOfPerson, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.NameOfPerson, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.NameOfPerson, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PurposeForGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.PurposeForGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.PurposeForGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyReturned, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyReturned, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyReturned, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
is there another way to achieve this with placing that modal into another view
javascript c# asp.net-mvc razor bootstrap-modal
You can't use two different models in a single view. You could approach this using aViewModel
or possibly apartial view
.
– Wubbler
Jan 3 at 13:50
@Wubbler can you suggest me any article with using partial view
– kunals
Jan 3 at 13:58
@kunals There are a huge range of materials available online, Google is your friend.
– Darkoj1
Jan 3 at 15:21
add a comment |
i want to load Modal as popup on button click through which user can save info in the database problem i am facing is my partial view which consist of that button has
IEnumerable modal and the modal form consist of normal model like @model Key so one model overlapping other and it is not working.
Here is my view
@model IEnumerable<RoomTypeView>
<div class="card border rounded DropShadow" style="border-top-right-radius:50%;">
<div class="card-body">
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.RoomNo)
@Html.DisplayFor(modelItem => item.GuestName)
@($"{item.CheckIn:dd/MMM} - {item.CheckOut:dd/MMM}")
@Html.DisplayFor(modelItem => item.Status)
<div class="form-inline">
<button type="button" class="btn btn-default modalkey" data-toggle="modal" data-target="#myModal"><i class="fas fa-key" style="@(item.Status.HasFlag(EnumHkStatus.Repair) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-broom" style="@(item.Status.HasFlag(EnumHkStatus.Cleaning) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-clipboard-list" style="@(item.Status.HasFlag(EnumHkStatus.InventoryCheck) ? "color:red;": "")"></i></button>
</div>
@Html.DisplayFor(modelItem => item.Comments)
}
</div>
</div>
@model KeyLog
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Key Log</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@if (Model?.KeyLogId > 0)
{
@Html.HiddenFor(model => model.KeyLogId)
}
<div class="form-group">
@Html.LabelFor(model => model.UserId, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UserId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NameOfPerson, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.NameOfPerson, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.NameOfPerson, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PurposeForGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.PurposeForGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.PurposeForGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyReturned, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyReturned, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyReturned, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
is there another way to achieve this with placing that modal into another view
javascript c# asp.net-mvc razor bootstrap-modal
i want to load Modal as popup on button click through which user can save info in the database problem i am facing is my partial view which consist of that button has
IEnumerable modal and the modal form consist of normal model like @model Key so one model overlapping other and it is not working.
Here is my view
@model IEnumerable<RoomTypeView>
<div class="card border rounded DropShadow" style="border-top-right-radius:50%;">
<div class="card-body">
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.RoomNo)
@Html.DisplayFor(modelItem => item.GuestName)
@($"{item.CheckIn:dd/MMM} - {item.CheckOut:dd/MMM}")
@Html.DisplayFor(modelItem => item.Status)
<div class="form-inline">
<button type="button" class="btn btn-default modalkey" data-toggle="modal" data-target="#myModal"><i class="fas fa-key" style="@(item.Status.HasFlag(EnumHkStatus.Repair) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-broom" style="@(item.Status.HasFlag(EnumHkStatus.Cleaning) ? "color:red;": "")"></i></button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal"><i class="fas fa-clipboard-list" style="@(item.Status.HasFlag(EnumHkStatus.InventoryCheck) ? "color:red;": "")"></i></button>
</div>
@Html.DisplayFor(modelItem => item.Comments)
}
</div>
</div>
@model KeyLog
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Key Log</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@if (Model?.KeyLogId > 0)
{
@Html.HiddenFor(model => model.KeyLogId)
}
<div class="form-group">
@Html.LabelFor(model => model.UserId, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.UserId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NameOfPerson, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.NameOfPerson, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.NameOfPerson, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PurposeForGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.PurposeForGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.PurposeForGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyGiven, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyGiven, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyGiven, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateKeyReturned, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.DateKeyReturned, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DateKeyReturned, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
is there another way to achieve this with placing that modal into another view
javascript c# asp.net-mvc razor bootstrap-modal
javascript c# asp.net-mvc razor bootstrap-modal
asked Jan 3 at 13:29
kunalskunals
287
287
You can't use two different models in a single view. You could approach this using aViewModel
or possibly apartial view
.
– Wubbler
Jan 3 at 13:50
@Wubbler can you suggest me any article with using partial view
– kunals
Jan 3 at 13:58
@kunals There are a huge range of materials available online, Google is your friend.
– Darkoj1
Jan 3 at 15:21
add a comment |
You can't use two different models in a single view. You could approach this using aViewModel
or possibly apartial view
.
– Wubbler
Jan 3 at 13:50
@Wubbler can you suggest me any article with using partial view
– kunals
Jan 3 at 13:58
@kunals There are a huge range of materials available online, Google is your friend.
– Darkoj1
Jan 3 at 15:21
You can't use two different models in a single view. You could approach this using a
ViewModel
or possibly a partial view
.– Wubbler
Jan 3 at 13:50
You can't use two different models in a single view. You could approach this using a
ViewModel
or possibly a partial view
.– Wubbler
Jan 3 at 13:50
@Wubbler can you suggest me any article with using partial view
– kunals
Jan 3 at 13:58
@Wubbler can you suggest me any article with using partial view
– kunals
Jan 3 at 13:58
@kunals There are a huge range of materials available online, Google is your friend.
– Darkoj1
Jan 3 at 15:21
@kunals There are a huge range of materials available online, Google is your friend.
– Darkoj1
Jan 3 at 15:21
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023251%2fhow-to-use-modal-popup-in-my-partial-view-in-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54023251%2fhow-to-use-modal-popup-in-my-partial-view-in-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can't use two different models in a single view. You could approach this using a
ViewModel
or possibly apartial view
.– Wubbler
Jan 3 at 13:50
@Wubbler can you suggest me any article with using partial view
– kunals
Jan 3 at 13:58
@kunals There are a huge range of materials available online, Google is your friend.
– Darkoj1
Jan 3 at 15:21