I have a razor view a part of which populates the mobile number of the logged in user using partial view
<div class="form-group">
<div class="col-md-10">
@Html.Action("ShopOwnerEditMobilePartial", "ManageShop", new { appUserId = Model.ApplicationUserId })
</div>
<br />
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="button" value="Save Changes" onclick="updateMobile()" class="btn btn-primary btn-block pull-right" />
</div>
</div>
</div>
Here is the controller code
public ActionResult ShopOwnerEditMobilePartial(string appUserId)
{
Repository rep = new Repository();
ViewBag.MobileNumber= rep.GetMobileNumberByAppUserId(appUserId);
return PartialView("_ShopOwnerEditMobilePartial");
}
here is the html code of the razor view
<input type="text" class="form-control" maxlength="20" id="MobileBox"
name="crimeRef" placeholder="Mobile Number"
value="@(ViewBag.MobileNumber ?? String.Empty)"/>
Here is my code for jquery which fails to get value by using MobileBox Id
var CityNewValue="";
function updateCity()
{
CityNewValue=$('#CityDDL').val();
$.ajax({
url: '@Url.Action("updateCity", "ManageShop")',
method: 'post',
data: { shopId:@Model.ShopId,NewCityID:CityNewValue}, //the data to be passed to the server
dataType: 'json', // data that we are expecting back from the server
success: function (data) { // data variable will contain the data fetched from the server
$('#successAlert').slideDown();
},
error: function (err) {
}
});
}
the problem comes when I try to get edited value of mobile number , there comes an uncaught exception against both MobileBox id and updateCity() function defined in partial view