Home > DeveloperSection > Forums > how to set id to Html.TextBox item on MVC
Ashish Pandey

Total Post:128

Points:898
Posted on    September-28-2013 4:12 AM

 ASP.NET MVC ASP.NET MVC 
Ratings:


 1 Reply(s)
 4111  View(s)
Rate this:

Im trying to catch the textbox element by javascript, in order to put text into it. so how to set id to the textbox ??

        <tr>
                    // Id to this textbox
            <td>@Html.TextBoxFor(item => item.OperationNo)</td>
        </tr>

and then to put text into it by JS

   document.getElementById("Textbox id").Text= " Some text " ;          


Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    September-28-2013 6:41 AM

Hey Ashish!

You can use below code for resolve that problem:

function steVal() {
        document.getElementById('txtPlace').value = "Set The Text";
    }
 @Html.TextBoxFor(m => m.OperationNo,new { @id = "txtPlace",@name="txtPlace" })

Don't want to miss updates? Please click the below button!

Follow MindStick