This is my Index view.
@model MultipleInstance.Order
@{
ViewBag.Title = "Index";
}
@using (Html.BeginForm("ProcessForm", "Default1", FormMethod.Post))
{
<table>
<tr>
<td>@Html.LabelFor(m => m.OrderID_)</td>
<td>@Html.TextBoxFor(m => m.OrderID_)</td>
</tr>
<tr>
<td>@Html.LabelFor(m => m.CustomerID_)</td>
<td>@Html.TextBoxFor(m => m.CustomerID_)</td>
</tr>
<tr>
<td>@Html.LabelFor(m=>m.SelectType)</td>
<td>@Html.DropDownListFor(m => m.SelectType, @ViewBag.docid as SelectList, "Select document Type")</td>
</tr>
</table>
}
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="//code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="scripts/jquery-1.8.2.js"></script>
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#SelectType").change(function () {
$("#log").ajaxError(function (event, jqxhr, settings, exception) {
alert(exception);
});
$.get('@Url.Action("RacersByCountryPartial")',
{ id: countrySelected }, function (data) {
$("#container").html(data);
});
});
});
</script>
<h3>Shipping Address</h3>
<div id="div2">
@Html.Partial("~/Views/_Address.cshtml",
new ViewDataDictionary()
{
TemplateInfo = new TemplateInfo()
{ HtmlFieldPrefix = "ShippingAddress" } })
</div>
<p> <input type="submit" value="Submit1" /></p>
Here I am rendering one view and in future I want to implement somemore views. It works fine. But I am calling
$.get('@Url.Action("RacersByCountryPartial")',
bcs some selection is there to display view. this is my action method.
[HttpGet]
public PartialViewResult RacersByCountryPartial(string id)
{
Address ad = new Address();
string id1 = id.Trim();
if (id1 == "Passport")
return PartialView("~/Views/_Address.cshtml", ad);
}
Actually from here i want to render my partial view but inside action method how can i specify Templateinfo and htmlfieldprefix?
This is my _address view.
@model MultipleInstance.Address
@Html.LabelFor(m => m.Street1) | @Html.TextBoxFor(m => m.Street1) |
@Html.LabelFor(m => m.Street2) | @Html.TextBoxFor(m => m.Street2) |
@Html.LabelFor(m => m.Country) | @Html.TextBoxFor(m => m.Country) |
@Html.LabelFor(m => m.PostalCode) | @Html.TextBoxFor(m => m.PostalCode) |
This is my model. Order.cs
public partial class Order
{
public int Id { get; set; }
public string OrderID_ { get; set; }
public string CustomerID_ { get; set; }
public string SelectType { get; set; }
public Address ShippingAddress { get; set; }
}