Tuesday, 16 June 2015

How to use literal in asp.net ?

            
Design Page : -

            <div>
               <asp:Literal ID="ltrlTest" runat="server" />
            </div>

Code Behind Page : -

            if(!IsPostBack)
            {
                String name = "Deepak Sharma";

                StringBuilder sb = new StringBuilder();
                sb.Append("<table>"); // Start table

                //table rows
                sb.Append("<tr><td>Name : </td><td><input id='txtName' type='text' value=" +                            name + " placeholder='Enter Name' style='color:Red;'></td></tr>");
                sb.Append("<tr><td>Address : </td><td>Gurgaon</td></tr>");

                sb.Append("</table>"); // End table
                ltrlTest.Text = sb.ToString(); // Bind literals

            }

Output : - 


No comments:

Post a Comment

Thanks for comments.