trouble in creating html table through c sharp
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: trouble in creating html table through c sharp

  1. #1
    Join Date
    Jul 2011
    Posts
    1

    Unhappy trouble in creating html table through c sharp

    Hi guys,

    I am trying to create a html table through c sharp. I opened a new web application and typed the following in default.aspx.cs file


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Drawing;
    using System.Drawing.Design;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;
    using System.Drawing.Printing;
    using System.Drawing.Text;


    namespace TablePOC
    {
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    Table tbl = new Table();
    tbl.ID = "table1";
    tbl.BorderStyle = BorderStyle.Dotted;
    tbl.GridLines = GridLines.Both;
    this.Controls.Add(tbl);


    TableRow rw1 = new TableRow();
    TableCell cell1 = new TableCell();
    cell1.Width = 450;

    Label text1 = new Label();
    text1.Text = "there are large number of people who were trapped in the avalanche ";
    cell1.Controls.Add(text1);
    rw1.Cells.Add(cell1);
    tbl.Controls.Add(rw1);



    TableRow rw2 = new TableRow();
    TableCell cell2 = new TableCell();
    cell2.Width = 450;
    Label text2 = new Label();
    text2.Text = "the blue wild fox jumped over the fence and ran away never to return again ";
    cell2.Controls.Add(text2);
    rw2.Cells.Add(cell2);
    tbl.Controls.Add(rw2);

    }
    }
    }

    my requirement is that I want each cell of the table to have 3 different colors. I have added 2 cells in 2 rows in d above code. Its easy to add 1 color as background color for a cell. But, I want to add 3 colors as background color for the cell such that, if the cell is say 100px width, the first 30px of the cell should be green, the second 30px should be yellow and the last 40px should be pink. Can anybody help me in dis ? Thanks in advance

  2. #2
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: trouble in creating html table through c sharp

    I know this probably isn't much help, but since nobody has replied... I'm thinking there just is no table cell parameter that is going to provide for a multi-colored background display... I think you are going to need some CSS magic to create some sort of display element you can add to the cell that looks how you want.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center