Monday, March 18, 2013

How to create html table at runtime to display content dynamicaaly.

 How to assign css style to dynamic control,solution is here.  
 Here i am showing how can we display textual content in runtime created  
 table and also we can use css class for this runtime created table tr and td.  
 Steps:  
 1.Take a div in html page as given below  
   <div class="msg" id="divOut" runat="server">
     
 2.Write below code in .cs file
   if (Convert.ToString(Convert.ToString(Session["userid"]) =="2511")  
      {  
           divOut.Controls.Add(new LiteralControl("<table align='center'>"));            
           divOut.Controls.Add(new LiteralControl("<tr><td align='left'>This is a messsage for userid 2511."));  
           divOut.Controls.Add(new LiteralControl("</td></tr>"));  
           divOut.Controls.Add(new LiteralControl("<tr><td align='left'> you can write you message here."));  
           divOut.Controls.Add(new LiteralControl("</td></tr>"));  
           divOut.Controls.Add(new LiteralControl("</table>"));  
      }  
      else if (Convert.ToString(Session["userid"]) == "2641")  
      {  
           divOut.Controls.Add(new LiteralControl("<table align='center'>"));            
           divOut.Controls.Add(new LiteralControl("<tr><td class='HighlightsmallnormalBlack' align='center'>This is a messsage for userid 2511!"));  
           divOut.Controls.Add(new LiteralControl("</td></tr>"));  
           divOut.Controls.Add(new LiteralControl("</table>"));  
      }  
      Regards  
      Santosh Singh  

2 comments:

  1. Hi,For instance, if you are building Web Design Cochin pages then ones you see being promoted by the clan of internet marketers have more than likely been used by several thousand people already.Thanks.....

    ReplyDelete