change text of label on onchange event of @Html.TextboxFor in mvc3

asp.net-mvc, asp.net-mvc-3, javascript

Solution

Use this jquery syntax its work fine.

@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",@onchange = "onchangeevent();" })

function onchangeevent(){
        $('#txtid').val('sam');
    }

Problem

I am working with MVC3 Razor. I want to change the text of label on onchange event of @Html.TextboxFor. Here is my code for what I am trying: On View: ``` @Html.TextBoxFor(x => x.ItnScanCaseCode, new { @onchange = "event();" }) ``` JavaScript: ``` function event() { document.getElementById('lblSelectedProductName').value ="sam"; } ``` But it's not working.

Original source