Display Partial view after submit button

The name of the pictureThe name of the pictureThe name of the pictureClash 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;
))
);






share|improve this question





















  • Can anyone out there who can please review my code and give me some ideas?
    – Raj
    Apr 11 at 22:19
















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;
))
);






share|improve this question





















  • Can anyone out there who can please review my code and give me some ideas?
    – Raj
    Apr 11 at 22:19












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;
))
);






share|improve this question













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;
))
);








share|improve this question












share|improve this question




share|improve this question








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
















  • 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















active

oldest

votes











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");

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: "196"
;
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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

Greedy Best First Search implementation in Rust

Function to Return a JSON Like Objects Using VBA Collections and Arrays

C++11 CLH Lock Implementation