I am having problem in setting a name attribute on a dynamic html control, my setted name isn't getting, what its getting is something like "ctl120" etc... how to get rid of this? TextBox tempInput = new TextBox(); tempInput.Text = row["TimeIn"].ToString(); tempInput.Attributes.Add("id", "txtTimeIn" + i.ToString()); tempInput.Attributes.Add("name",i.ToString()); tempInput.Attributes.Add("value", tempInput.Attributes["name"]); tempData.Controls.Add(tempInput); tempRow.Cells.Add(tempData); Code (markup): Outputs: <input name="ctl20" value="1" type="text"> Code (markup):
.NET needs a hook to your control - so it needs to set the name if it is going to be created by .NET - Name is off limits... even if you gave it a name via tags as in <a href="blah" runat="server" name="hehe" /> it will alter the html created control name.