How to apply Style to a Web Server control programmatically

User Interface <asp:TextBox id=’TextBox1′ style=’Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 64px’ runat=’server’>Syncfusion</asp:TextBox> <asp:Button id=’Button1′ style=’Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 120px’ runat=’server’ Text=’Button’></asp:Button> <asp:CheckBox id=’CheckBox1′ style=’Z-INDEX: 103; LEFT: 40px; POSITION: absolute; TOP: 200px’ runat=’server’ Text=’Syncfusion’></asp:CheckBox> VB.NET Create a function Protected Function createStyleForControl(ByVal _forecolor As Color, ByVal _backcolor As Color, ByVal _fontbold As Boolean) As Style Dim s As Style = New Style s.ForeColor = _forecolor s.BackColor = _backcolor s.Font.Bold = _fontbold Return s End Function In Page_Load Dim textboxStyle As Style = createStyleForControl(Color.Pink, Color.Yellow, False) Dim buttonStyle As Style = createStyleForControl(Color.Blue, Color.Teal, True) Dim checkboxStyle As Style = createStyleForControl(Color.AliceBlue, Color.PowderBlue, False) TextBox1.ApplyStyle(textboxStyle) Button1.ApplyStyle(buttonStyle) CheckBox1.ApplyStyle(checkboxStyle) C# Create a function protected Style createStyleForControl(Color _forecolor ,Color _backcolor ,bool _fontbold ) { Style s = new Style(); s.ForeColor = _forecolor; s.BackColor =_backcolor; s.Font.Bold = _fontbold; return s; } In Page_Load Style textboxStyle=createStyleForControl (Color.Pink, Color.Yellow, false ); Style buttonStyle=createStyleForControl (Color.Blue, Color.Teal, true ); Style checkboxStyle =createStyleForControl (Color.AliceBlue, Color.PowderBlue, false ); TextBox1.ApplyStyle(textboxStyle ); Button1.ApplyStyle (buttonStyle ); CheckBox1.ApplyStyle (checkboxStyle );

How to change the text color of a linkbutton control

Pseudo-elements are fictional elements that do not exist in HTML. They address the element’s sub-part. There are 2 types of pseudo-elements as “first-line pseudo-element’ and ’first-letter pseudo-element’. Pseudo-element is created by a colon followed by pseudo-element’s name,e.g: P:first-line H1:first-letter and can be combined with normal classes; e.g: P.initial:first-line The first line of this paragraph will be displayed in uppercase letters

How can the a client side function be called on a button click event?

In 2.0 Button control has a property OnClientClick which is used to call a client side function before postback. <asp:Button ID=’Button1′ runat=’server’ Text=’Button’ OnClientClick=’ClientFunction()’/> <script> functionClientFunction() { alert(‘ClientFunctionCalled’); } </script>

How can you generate a clock in javascript?

A clock can be generated using the javascript function as given below. <html> <head> <script language=’JavaScript’> function startclock() { var thetime=new Date(); var nhours=thetime.getHours(); var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); var nday=thetime.getDay(); var nmonth=thetime.getMonth(); var ntoday=thetime.getDate(); var nyear=thetime.getYear(); var AorP=’ ‘; if (nhours>=12) AorP=’P.M.’; else AorP=’A.M.’; if (nhours>=13) nhours-=12; if (nhours==0) nhours=12; if (nsecn<10) nsecn=’0’+nsecn; if (nmins<10) nmins=’0’+nmins; if (nday==0) nday=’Sunday’; if (nday==1) nday=’Monday’; if (nday==2) nday=’Tuesday’; if (nday==3) nday=’Wednesday’; if (nday==4) nday=’Thursday’; if (nday==5) nday=’Friday’; if (nday==6) nday=’Saturday’; nmonth+=1; if (nyear<=99) nyear= ’19’+nyear; if ((nyear>99) && (nyear<2000)) nyear+=1900; document.clockform.clockspot.value=nhours+’: ‘+nmins+’: ‘+nsecn+’ ‘+AorP+’ ‘+nday+’, ‘+nmonth+’/’+ntoday+’/’+nyear; setTimeout(’startclock()’,1000); } </script> </head> <body> <form name=’clockform’> Current Time: <INPUT TYPE=’text’ name=’clockspot’ size=’40’> </form> <script language=’JavaScript’> startclock(); </script> </body> </html>