I see this type of code when looking through our working code base:
private Button AddClearButton()
{
return new Button
{
OnClientClick =
string.Format(@"$('.{0}').css('background-color', '#FBFBFB');
$('#' + {1}).val('');
$('#' + {2}).val('');
return false;", _className, _hiddenImageNameClientId, _hiddenPathClientId),
Text = LanguageManager.Instance.Translate("/button/clear")
};
}
or
_nameAndImageDiv = new HtmlGenericControl("div");
var imageDiv = new HtmlGenericControl("div");
imageDiv.Attributes.Add("style", "width: 70px; height: 50px; text-align: center; padding-top: 5px; ");
var nameDiv = new HtmlGenericControl("div");
nameDiv.Attributes.Add("style", "width: 70px; word-wrap: break-word; text-align: center;");
var image = new HostingThumbnailImage();
Disclaimer: I have not worked with CSS before. but I heard that we should separate css, js, html, C#, other than put them together.
so, is the above code bad? If yes, how is the better approach?