Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Two Customer Type And I use Service Known Type in WCF the Customer Type is Main Customer And Sub Customer. I have Dropdown List to select Customer Type When I select The Main Customer I need The Sub Customer Partial View to be hidden And vice versa

@model SoqiaRazorProject.CustomerService.CustomerData

<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

@{
ViewBag.Title = "Customer Data";
}

CustomerData

@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)


Customer Data


@Html.LabelFor(model => model.CustomerID)


@Html.EditorFor(model => model.CustomerID)
@Html.ValidationMessageFor(model => model.CustomerID)



@Html.LabelFor(model => model.CardID)


@Html.EditorFor(model => model.CardID)
@Html.ValidationMessageFor(model => model.CardID)



@Html.LabelFor(model => model.Type)


@Html.DropDownList("ddlCustomerType",(SelectList)ViewBag.ddlCustomerType,new{@id="ddlCustomerType"})

@Html.ValidationMessageFor(model => model.Type)




@Html.LabelFor(model => model.NationalityID)


@Html.DropDownList("ddlNationality")
@Html.ValidationMessageFor(model => model.NationalityID)



@Html.LabelFor(model => model.FamilyName)


@Html.EditorFor(model => model.FamilyName)
@Html.ValidationMessageFor(model => model.FamilyName)



@Html.LabelFor(model => model.FirstName)


@Html.EditorFor(model => model.FirstName)
@Html.ValidationMessageFor(model => model.FirstName)



@Html.LabelFor(model => model.FatherName)


@Html.EditorFor(model => model.FatherName)
@Html.ValidationMessageFor(model => model.FatherName)



@Html.LabelFor(model => model.GrandFatherName)


@Html.EditorFor(model => model.GrandFatherName)
@Html.ValidationMessageFor(model => model.GrandFatherName)



and I write this J-Query Code to Hide/Show The Partial view
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("ddlCustomerType").change(function HideControls() {
var val = $("ddlCustomerType").val();
if (val == 2) {
$("MainCustomerDiv").hide();
$("SubCustomerDiv").show();
}
else if (val == 3) {
$("SubCustomerDiv").hide();
$("MainCustomerDiv").show();
}

})
});
</script>


@Html.Partial("MainCustomerData")


@Html.Partial("SubCustomerData")



<input type="submit" value="Create" />


}


@Html.ActionLink("Back to List", "Index")




When I Run the application "I try to change the dropdown list values But The Partial View Not Hidden"
Posted
Comments
medo67866 26-Jun-14 4:29am    
The two partial inside Div Tag but I don't know why It's not appear
SwarupDChavan 27-Jun-14 3:38am    
hey can u plz show how have you appended the partial view to the Div and the rest of the code as well coz tht would be really helpful

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900