---
title: "How to give the id to the html textbox?"  
description: "How to give the id to the html textbox?"  
author: "Anonymous User"  
published: 2013-09-25  
updated: 2013-09-25  
canonical: https://www.mindstick.com/forum/1529/how-to-give-the-id-to-the-html-textbox  
category: "html5"  
tags: ["html5"]  
reading_time: 1 minute  

---

# How to give the id to the html textbox?

How to give the id to the html [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview)?

My [html tag](https://www.mindstick.com/forum/78/how-avoid-the-html-tag-and-remove-the-formating-of-copy-in-ajax-editor) looks like this

<%=Html.TextBox("[username](https://www.mindstick.com/forum/12798/there-is-no-viewdata-item-of-type-ienumerable-selectlistitem-that-has-the-key-username)")%>

Any [suggestions](https://www.mindstick.com/blog/299486/how-to-write-for-your-audience)?

## Replies

### Reply by Anonymous User

By default, the TextBoxFor element will have an ID and NAME property that matches the expression property of the element.

@[Html](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript).TextBoxFor(model => model.ProductName)

In this example, the ID and NAME would be "ProductName"

If you want to specify an ID or NAME that's different from the expression property, you can use the htmlAttributes overload param.

@Html.TextBoxFor(model => model.ProductName, new { id = "myProduct", name = "myProduct" })


---

Original Source: https://www.mindstick.com/forum/1529/how-to-give-the-id-to-the-html-textbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
