我正在尝试对复选框检查进行 ajax 调用。
这是我的代码:
<%@ Control Language="C#"
Inherits="System.Web.Mvc.ViewUserControl<EmsAdmin.Models.User>" %>
<%@ Import Namespace="EmsAdmin.Models" %>
<script type="text/javascript">
//<![CDATA[
alert("I am here");
var manuId = ('#value');
alert(manuId);
$('#value:checkbox').change(function () {
var taskInput;
alert("I am here" +'#<%: Model.ManufacturerId %>');
$.ajax({
url: "/ReportUserVerification/GetCountriesForManufacturer/<%:Model.ManufacturerId%>",
type:'get',
success: function (data) {
taskInput = data;
var countriesArray = [];
for (var i = 0; i < data.length; i++) {
var item1 = data[i];
alert(item1);
if (item1 != null) {
countriesArray.push(item1);
}
}
}
});
});
//]]>
<script type="text/javascript">
//<![CDATA[
alert("I am here");
var manuId = ('#value');
alert(manuId);
$('#value').change(function () {
var taskInput;
alert("I am here" +'#<%: Model.ManufacturerId %>');
$.ajax({
url:
"/ReportUserVerification/GetCountriesForManufacturer/<%:Model.ManufacturerId%>",
type:'get',
success: function (data) {
taskInput = data;
var countriesArray = [];
for (var i = 0; i < data.length; i++) {
var item1 = data[i];
alert(item1);
if (item1 != null) {
countriesArray.push(item1);
}
}
}
});
});
//]]>
</script>
<%= Html.ValidationSummary("Edit was unsuccessful. Please correct the errors and try
again.") %>
<% using (Html.BeginForm())
{%>
<%= Html.AntiForgeryToken() %>
<p>
<%= Html.LabelFor(e=>e.Id,"Id:") %>
<%: Model.Id %>
</p>
<p>
<%= Html.LabelFor(e=>e.PersonId,"Person:") %>
<%= Html.DropDownListFor(e => e.PersonId, (SelectList)ViewData["allPersons"], "Select
person", new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.Person,"") %>
</p>
<p>
<%= Html.LabelFor(e=>e.Email,"Email:") %>
<%= Html.TextBoxFor(e => e.Email, new { @style = "width:250px;" })%>
<%= Html.ValidationMessageFor(e=>e.Email,"") %>
</p>
<p>
<%= Html.LabelFor(e=>e.Corporation.Description,"Corporation:") %>
<%= Html.TextBoxFor(e => e.Corporation.Description, new { @style = "width:250px;" })%>
<%= Html.ValidationMessageFor(e=>e.Corporation.Description,"") %>
</p>
<hr />
<h2>
Approve User</h2>
<p>
<%= Html.LabelFor(e=>e.Approve,"Aprrove User:") %>
<%= Html.CheckBoxFor(e=> e.Approve,Model.Approve) %><span> Switch this on if you
want to
add regitrar </span>
<%= Html.ValidationMessageFor(e=>e.Approve,"") %>
</p>
如果需要,多选品牌:
<div id ="ManufacturerId"<%:Model.ManufacturerDescription %>>
<p>
<%= Html.LabelFor(e=> e.ManufacturerDescription,"Brand:") %>
<br/>
</p>
<%for (int i = 0; i < Model.Manufacturers.Count;i++ )
{%>
<p>
<%:Html.HiddenFor(e=>e.Manufacturers[i].Id) %>
<%:Html.CheckBoxFor(x => x.Manufacturers[i].IsSelected) %>
<%:Html.LabelFor(x => x.CountryNames[i].IsSelected,
Model.Manufacturers[i].Description)%>
</p>
<%} %>
</div>
<%--<p>
<%= Html.LabelFor(e=>e.ManufacturerDescription,"Brand:") %>
<%= Html.DropDownListFor(e => e.ManufacturerDescription,
(SelectList)ViewData["allManufacturers"], "Select Brands", new { @style = "width:
255px;" })%>
<%= Html.ValidationMessageFor(e=>e.ManufacturerDescription,"") %>
</p>
<%= Html.LabelFor(e=>e.CountryName,"Country:") %>
<%= Html.DropDownListFor(e => e.CountryName, (SelectList)ViewData["allCountries"],
"Select Countries", new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.CountryName,"") %>
</p>--%>
<hr />
<h2>
Select Role:</h2>
<p>
<%= Html.LabelFor(e => e.Role, "Role:")%>
<%= Html.DropDownListFor(e => e.Role, (SelectList)ViewData["allRoles"], "Select
Roles",
new { @style = "width: 255px;" })%>
<%= Html.ValidationMessageFor(e=>e.Role,"") %>
</p>
<p>
<input type="submit" value="Save" />
<%= Html.ActionLink("Cancel","Details",new {id=Model.Id},new {@title="exit without
saving"}) %>
</p>
<% } %>