Display Partial view after submit button
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
Please suggest a good way of submitting the partial view form after submit. Currently, I am doing it in this way which I think is not a proper way.
As there are more than one records in the main view and every record has a select button which gives me partial view based Id and <div id="Partial"></div>
displays the partial view.
Main View
<table id="tblInfo" >
<tr>
<th>@Html.DisplayNameFor(m =>m.Name)</th>
</tr>
@foreach (var item in Model)
<tr>
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>
<input class="search" type="button" value="Select" data-assigned="@item.Id" />
</td>
</tr>
</table>
<div id="Partial"></div>
Partial view _Abc.cshtml
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new id = "myform" ))
@Html.TextBoxFor(m => m.txtAddress)
<button type="submit">Page</button>
Controller to submit the partial view form
[HttpPost]
public ActionResult Index(ClsInfo clsInfo)
string Id = Session["Id"].ToString();
Details.produceData(clsInfo);
if (Id == "A01")
return PartialView("~/Views/Home/_Abc.cshtml");
else if (Id == "A02")
return PartialView("~/Views/Home/_Cde.cshtml", model);
return PartialView();
Ajax call after submission
$(document).ready(function ()
var url = '@Url.Action("Home")';
$('#Partial').on('submit', '#myform', (function ()
if (!$(this).valid())
return;
$.post(url, $(this).serialize(), function (response)
$('#Partial').html(response);
);
return false;
))
);
javascript jquery ajax asp.net-mvc
add a comment |Â
up vote
0
down vote
favorite
Please suggest a good way of submitting the partial view form after submit. Currently, I am doing it in this way which I think is not a proper way.
As there are more than one records in the main view and every record has a select button which gives me partial view based Id and <div id="Partial"></div>
displays the partial view.
Main View
<table id="tblInfo" >
<tr>
<th>@Html.DisplayNameFor(m =>m.Name)</th>
</tr>
@foreach (var item in Model)
<tr>
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>
<input class="search" type="button" value="Select" data-assigned="@item.Id" />
</td>
</tr>
</table>
<div id="Partial"></div>
Partial view _Abc.cshtml
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new id = "myform" ))
@Html.TextBoxFor(m => m.txtAddress)
<button type="submit">Page</button>
Controller to submit the partial view form
[HttpPost]
public ActionResult Index(ClsInfo clsInfo)
string Id = Session["Id"].ToString();
Details.produceData(clsInfo);
if (Id == "A01")
return PartialView("~/Views/Home/_Abc.cshtml");
else if (Id == "A02")
return PartialView("~/Views/Home/_Cde.cshtml", model);
return PartialView();
Ajax call after submission
$(document).ready(function ()
var url = '@Url.Action("Home")';
$('#Partial').on('submit', '#myform', (function ()
if (!$(this).valid())
return;
$.post(url, $(this).serialize(), function (response)
$('#Partial').html(response);
);
return false;
))
);
javascript jquery ajax asp.net-mvc
Can anyone out there who can please review my code and give me some ideas?
â Raj
Apr 11 at 22:19
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Please suggest a good way of submitting the partial view form after submit. Currently, I am doing it in this way which I think is not a proper way.
As there are more than one records in the main view and every record has a select button which gives me partial view based Id and <div id="Partial"></div>
displays the partial view.
Main View
<table id="tblInfo" >
<tr>
<th>@Html.DisplayNameFor(m =>m.Name)</th>
</tr>
@foreach (var item in Model)
<tr>
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>
<input class="search" type="button" value="Select" data-assigned="@item.Id" />
</td>
</tr>
</table>
<div id="Partial"></div>
Partial view _Abc.cshtml
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new id = "myform" ))
@Html.TextBoxFor(m => m.txtAddress)
<button type="submit">Page</button>
Controller to submit the partial view form
[HttpPost]
public ActionResult Index(ClsInfo clsInfo)
string Id = Session["Id"].ToString();
Details.produceData(clsInfo);
if (Id == "A01")
return PartialView("~/Views/Home/_Abc.cshtml");
else if (Id == "A02")
return PartialView("~/Views/Home/_Cde.cshtml", model);
return PartialView();
Ajax call after submission
$(document).ready(function ()
var url = '@Url.Action("Home")';
$('#Partial').on('submit', '#myform', (function ()
if (!$(this).valid())
return;
$.post(url, $(this).serialize(), function (response)
$('#Partial').html(response);
);
return false;
))
);
javascript jquery ajax asp.net-mvc
Please suggest a good way of submitting the partial view form after submit. Currently, I am doing it in this way which I think is not a proper way.
As there are more than one records in the main view and every record has a select button which gives me partial view based Id and <div id="Partial"></div>
displays the partial view.
Main View
<table id="tblInfo" >
<tr>
<th>@Html.DisplayNameFor(m =>m.Name)</th>
</tr>
@foreach (var item in Model)
<tr>
<td>@Html.DisplayFor(modelItem => item.Name)</td>
<td>
<input class="search" type="button" value="Select" data-assigned="@item.Id" />
</td>
</tr>
</table>
<div id="Partial"></div>
Partial view _Abc.cshtml
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new id = "myform" ))
@Html.TextBoxFor(m => m.txtAddress)
<button type="submit">Page</button>
Controller to submit the partial view form
[HttpPost]
public ActionResult Index(ClsInfo clsInfo)
string Id = Session["Id"].ToString();
Details.produceData(clsInfo);
if (Id == "A01")
return PartialView("~/Views/Home/_Abc.cshtml");
else if (Id == "A02")
return PartialView("~/Views/Home/_Cde.cshtml", model);
return PartialView();
Ajax call after submission
$(document).ready(function ()
var url = '@Url.Action("Home")';
$('#Partial').on('submit', '#myform', (function ()
if (!$(this).valid())
return;
$.post(url, $(this).serialize(), function (response)
$('#Partial').html(response);
);
return false;
))
);
javascript jquery ajax asp.net-mvc
edited Mar 26 at 0:35
Jamalâ¦
30.1k11114225
30.1k11114225
asked Mar 19 at 22:29
Raj
1011
1011
Can anyone out there who can please review my code and give me some ideas?
â Raj
Apr 11 at 22:19
add a comment |Â
Can anyone out there who can please review my code and give me some ideas?
â Raj
Apr 11 at 22:19
Can anyone out there who can please review my code and give me some ideas?
â Raj
Apr 11 at 22:19
Can anyone out there who can please review my code and give me some ideas?
â Raj
Apr 11 at 22:19
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f189979%2fdisplay-partial-view-after-submit-button%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Can anyone out there who can please review my code and give me some ideas?
â Raj
Apr 11 at 22:19