How can you apply skin styles to button?

Platform: ASP.NET| Category: CSS Styles and Themes

Apply Skin Styles to webcontrols(Textbox,button)


private Style CreateStyle(Color backClr, Color foreClr, int borderWidth, string fntName, int fntSize, bool fntBold, bool fntItalic /*Youcanaddmoreparameters to the method */)
{
	Style s = new Style();
	s.BackColor = backClr;
	s.ForeColor = foreClr;
	s.BorderWidth = borderWidth;
	s.Font.Name = fntName;
	s.Font.Size = fntSize;
	s.Font.Bold = fntBold;
	s.Font.Italic = fntItalic;
	return s;
} 

// This method applies a Style object to a WebControl
private void SetControlStyle(System.Web.UI.WebControls.WebControl ctrl,Style s)
{
	ctrl.ApplyStyle(s);
}

private void Button1_Click(object sender, System.EventArgs e)
{
	Style st = CreateStyle(Color.Green, Color.Yellow, 3,'Verdana', 10, true, true); 
	SetControlStyle(TextBox1, st);
	st = CreateStyle(Color.Red, Color.Black, 2,'Verdana', 12, true, true);
	SetControlStyle(Button1, st); 
}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.