Is there a way to set the position of the controls dynamically
Yes. <asp:Button id='Button1' style='Z-INDEX: 101; LEFT: 116px; POSITION: absolute; TOP: 152px' runat='server' Text='Move'></asp:Button> <asp:RadioButtonList id='RadioButtonList1' style='Z-INDEX: 103; LEFT: 87px; POSITION: absolute; TOP: 27px' runat='server' AutoPostBack='True'> <asp:ListItem Value='10px'>10 pixels</asp:ListItem> <asp:ListItem Value='100px'>100 pixels</asp:ListItem> <asp:ListItem Value='200px'>200 pixels</asp:ListItem> </asp:RadioButtonList> VB.NET Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ’ Put user code to initialize the page here If Not Page.IsPostBack Then Button1.Style.Add('LEFT', '1px') End If End Sub ’Page_Load Private Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged Button1.Style.Add('LEFT', RadioButtonList1.SelectedItem.Value.ToString()) End Sub ’RadioButtonList1_SelectedIndexChanged C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!Page.IsPostBack ) { Button1.Style.Add('LEFT', '1px'); } } private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) { Button1.Style.Add('LEFT',RadioButtonList1.SelectedItem.Value.ToString()); }
How to get the list of all System.Web.UI.WebControls in my page
<asp:Repeater runat='server' DataSource=’<%# GetControls() %>’ ID='Repeater1'> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate> <li> <%# DataBinder.Eval(Container.DataItem, 'Name') %> </li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater> VB.NET Protected Function GetControls() As ArrayList Dim arrList As New ArrayList() Dim t As Type For Each t In GetType(Page).Assembly.GetTypes() If t.Namespace = 'System.Web.UI.WebControls' And GetType(Control).IsAssignableFrom(t) Then arrList.Add(t) End If Next Return arrList End Function ’GetControls ’In Page_Load DataBind() C# protected ArrayList GetControls() { ArrayList arrList = new ArrayList(); foreach (Type t in typeof(Page ).Assembly.GetTypes()) { if (t.Namespace == 'System.Web.UI.WebControls' && typeof(Control).IsAssignableFrom(t)) arrList.Add(t); } return arrList; } //In Page_Load DataBind();
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 );
DataBinder.Eval imposes performance penalty on code as it uses late bound reflection. How can I replace this calls with explicit calls?
Change the Databinding Expression <%#DataBinder.Eval (Container.DataItem , 'StartDate' , '{0:c}')%> to In VB.NET <%#String.Format('{0:d}' , (CType(Container.DataItem, DataRowView))('StartDate'))%> C# <%#String.Format('{0:d}' , ((DataRowView)Container.DataItem)['StartDate'])%>
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