I have a scenario where I have to dynamically create a form based on user selection. There are several text fields on the form that should be added to the end in Total Textbox.
The way I distinguish between text fields added at the end is indicated below:
TextBox txt1 = new TextBox(); txt1.ID = "txt1"; txt1.CssClass = "addToTotal"; TextBox txt2 = new TextBox(); txt2.ID = "txt2"; txt2.CssClass = "addToTotal"; TextBox txt3 = new TextBox(); txt3.ID = "txt3"; txt3.CssClass = "txtTotalPoints"; PlaceHolder1.Controls.Add(txt1); PlaceHolder1.Controls.Add(txt2); PlaceHolder1.Controls.Add(txt3);
In fact, the site css file class does not have a css class named 'addToTotal' . It is simply used as a flag to notify me of an addition at the end.
It is good practice to add .CssClass, although the actual class does not exist. Are there any flaws in using this methodology?
source share