1

Project - ASP.Net 1.1 Website

I am creating dynamic HtmlInput controls and adding class, id and name attribute to it.

Example -

HtmlInput obj = new HtmlInput
obj.Attributes.Add("id", "A1");
obj.Attributes.Add("name", "A1");
obj.Attributes.Add("class", "Format");

Now during postback, i am tryin to read from Request.Form["A1"] but i cant read it, because the name attribute when checked in HTML is automatically renamed as "_Ct1"

Automatically changed by ASP.NET.

Can somebody, please help me retain my name field, so that i can read the value on postback ?

CıPhEr
  • 49
  • 1
  • 7
  • 1
    Set the `obj.ID` property directly instead of adding "id" and "name" attributes. – Michael Liu Jun 10 '13 at 03:06
  • Thanks for responding Michael. Yes ID property i had tried, but unfortunately the css class does not get applied for some strange reason if i do that. I add Class attribute seperately, but when i set the .ID property boom, CSS does not get applied, that the reason why my approach was to add attributes. Adding attributes, css class is applied everything works fine, but damn this name is automatically populated. :( – CıPhEr Jun 10 '13 at 07:44
  • What is the actual type of control you're creating? `HtmlInput` doesn't exist. – Michael Liu Jun 10 '13 at 13:46

1 Answers1

0

Michael Liu provided a solution, but he responded to my question, so i cant mark it as an answer. But it is the right thing to do, Use obj.ID = "myID" and this will be retained as your control name.

CıPhEr
  • 49
  • 1
  • 7