How to apply css style to each item of the dropdownlist or listbox control

The dropDownList has a bug which prevent us from assigning the style property to each item in the DropDownList. This bug confirmed by Microsoft in Microsoft Knowledge Base Article – 309338 For the workaround use a HTML dropdownlist with runat=server tag <SELECT id='DropDownList1' runat='server' > </SELECT> Use namespace System.Reflection VB.NET If Not Page.IsPostBack Then Dim col As FieldInfo For Each col In GetType(KnownColor).GetFields If col.FieldType Is GetType(Drawing.KnownColor) Then DropDownList1.Items.Add(New ListItem(col.Name, col.Name)) End If Next End If Dim i As Integer For i = 0 To DropDownList1.Items.Count - 1 DropDownList1.Items(i).Attributes.Add('style', 'background-color:' + DropDownList1.Items(i).Text) Next C# if (!IsPostBack) { foreach(FieldInfo col in typeof(KnownColor).GetFields() ) { if (col.FieldType == typeof(KnownColor) ) { DropDownList1.Items.Add(new ListItem(col.Name ,col.Name)); } } } for (int i= 0 ;i < DropDownList1.Items.Count;i++) { DropDownList1.Items[i].Attributes.Add('style', 'background-color:' + DropDownList1.Items[i].Text); }

Why does FormsAuthentication.Decrypt crashes when moving to another Server

The reason why the encrypted data couldn’t be decrypted on another machine is because the validation key in the original machine’s machine.config is set to AutoGenerate. This means that the generated keys are unique to each machine. A better solution will be to specify the validation key, so you can decrypt it across any machine with the same validation key. For more details on solution refer following article : Microsoft Knowledge Base Article – 313091 Microsoft Knowledge Base Article – 312906

How to run an exe from a ASP.NET page?

For security reasons, you can’t force a user to run any executable. Instead give user the option to click on it and download the executable, and execute it if he wants to. All you can do is put .exe in a directory on your web site and put a hyperlink to it on some page. Note : Be sure to secure this directory by deactivating all execution permissions both in the IIS console and in the directory ACL For more details refer INFO: Executing Files by Hyperlink and the File Download Dialog Box