I have a view which contains a partial view. I need to pass a value from the parent view into the partial view. I do this like so:

 <div>
   @Html.Partial("_DrugScan", new TIMS.Models._DrugScan() { ASNID = Model.ASNID })
</div>

The "_DrugScan" class contains only two properties, the ASNID and a UPC. The partial view uses a form to fill in the UPC like so:

@model TIMS.Models._DrugScan

@*@Scripts.Render("~Scripts/ScanDrugPost.js")*@



<div>
    @using (Html.BeginForm("DrugScan", "Receive", FormMethod.Post, new { @class = "form-horizontal", role = "form"}))
    {
        @Html.AntiForgeryToken()

        <dl class="dl-horizontal">
            <dt>
                @Html.Label("Scan Drug UPC")
            </dt>
            <dd>
                @Html.Kendo().MaskedTextBoxFor(x => x.UPC).Mask("000000000000").PromptChar("-").HtmlAttributes(new {@id="UPC_textbox"})
            </dd>
        </dl>

    }

</div>

The problem I have is that when I submit the form, the UPC property is filled out but the ASNID is back to null/default. I can hit a breakpoint in the page and see that the ASNID is getting set appropriately but is lost on submission. What am I doing wrong?

Related posts

Recent Viewed