Asp.net Literal control



asp:Literal control
Textual control is a rarely used control which is used to make static text on the web page.

Ideally, lexical control is rarely used to control which is used to make static text on the web page. When it is provided on the page, it is applied as a simple text

Unlike ASP: There is no property like label control, backclosure, foreclosure, border barrier, border style, borderwidth, height of lift control etc. This makes it more powerful, you can also put pure HTML content in it.


  Ex. Just a text inside Literal Control

 <tr>
                <td>
                    <asp:Label ID="Label1" AssociatedControlID="dropStatic" runat="Server" Text="Select color to change the background color the cell"></asp:Label>
                     <asp:DropDownList ID="DropDownList1" runat="server">
                        <asp:ListItem Text="Red" Value="red"></asp:ListItem>
                        <asp:ListItem Text="Blue" Value="blue"></asp:ListItem>
                        <asp:ListItem Text="Green" Value="green"></asp:ListItem>
                    </asp:DropDownList>

                    <asp:Button ID="Button1" runat="Server" OnClick="ChangeBackColor" Text="Change Label Text" />             

                </td>

                

                // Set the background color of the cell from server side event
                <td <asp:Literal ID="Literal2" runat="Server" />>
                    Ex. <asp:Literal ID="Literal3" runat="Server" Text="Just a text inside Literal Control"></asp:Literal>
                </td>
            </tr>

            // CODE BEHIND 
            // Fires when Button is clicked
            protected void ChangeBackColor(object sender, EventArgs e)
            {
                Literal1.Text = " bgcolor='" + dropStatic.SelectedValue + "'";
                litText.Text = "<div style='background-color:white;color:#000000'>Literl Control is powerful</div>";
            }

               
Share on Google Plus

About It E Research

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment