lundi 23 novembre 2015

sending value of model property as an ajax parameter

I have following form in my view-page

@using (Html.BeginForm())
{
   @Html.EditorFor(model => model.Product_ID)

}

<input id="idd" type="file" class="file">

I want to send above inserted Product_ID as ajax object route value before click the submit button of this form.for that I created it like this product_ID = Model.Product_ID but this product_ID getting null.

$('#idd').click(function () {

    $.ajax({
        url: '@Url.Action("CreateDirectory", "Home",new { product_ID = Model.Product_ID })',
        type: "POST",

controller

    [HttpPost]
    public JsonResult CreateDirectory(string product_ID)
    {
      ...........
    }

EDIT

using alert inside above script I try to show that Product_ID

alert('@Model.Product_ID');

same results not showing value

Aucun commentaire:

Enregistrer un commentaire