mardi 24 novembre 2015

value of a Model property send as a parameters to controller method in bootstrap-fileinput

I'm using the Bootstrap File Input plugin and I'm trying to get the product_ID Model property value from following form and send as a parameters to controller method.

this is the form

@model project_name.Models.relavantmodel

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

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

   // form sumbit button
   <input type = "submit" value="Create" /> 


I have following controller

    public ContentResult UploadFiles(string product_ID, string type)

Also I refer this question also

I'm trying to use following script for call upload method and send parameters

Approach 1 :

    type: 'POST',   
    uploadUrl: '/Home/UploadFiles', // server upload action
    uploadExtraData: { 'product_ID': document.getElementById('#Product_ID').value, 'type': "marketing_materials_EN" },


Approach 2 :

    type: 'POST',        
    uploadUrl: '@Url.Action("UploadFiles", "Home")',
    uploadExtraData: { product_ID: $('#Product_ID').val(), 'type': "marketing_materials_EN" },

Approach 3 :

        type: 'POST',        
        uploadUrl: '@Url.Action("UploadFiles", "Home" ,new {product_ID = @Model.Product_ID , type = "marketing_materials_EN" })',

But none above approach I cannot get the product_ID that I'm inserting, .But I can send type

Once put I debug point at controller method I can see type value is getting

enter image description here

and product_ID getting NULL

enter image description here

How can I get the product_ID here

Aucun commentaire:

Enregistrer un commentaire