TextBox.Style.Add

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

The following works great....
TextBox10.Style.Add(HtmlTextWriterStyle.TextAlign, "center");

Now I know that HtmlTextWriterStyle is an enumerations and that TextAlign is
int 36.

I am in a situation where I am getting passed the values of the enumeration
but if I say TextBox10.Style.Add(String1, String2) and String1 Contains 36
or "HtmlTextWriterStyle.36" or "TextAlign" the proper html does not get
rendered. The rendered html has exactly what string1 has.

What has to be in the value of string1 to get the html rendered correctly?

Thanks,

T
 
Hi Tina,

Why not pass around the HtmlTextWriterStyle value instead of a string representation?

If you don't have any choice in the matter, the following code should work as long as String1 is "TextAlign" or "36", but not
"HtmlTextWriterStyle.36":

// Parse String1 into an HtmlTextWriterStyle enum value using the Enum.Parse method and cast the result
HtmlTextWriterStyle parsedStyle = (HtmlTextWriterStyle) Enum.Parse(typeof(HtmlTextWriterStyle), String1);

textBox10.Style.Add(parsedStyle, String2);
 
Back
Top