Table cells background


G

Guest

Hi,
Can anyone tell me how to change a table cells background color or
background image in runtime with C#.

Karl-Inge
 
Ad

Advertisements

G

Guest

You can use the cssClass attribute, e.g.

..TableCell1
{
background-image:url("images/Image1.gif");
}

and in your C# code:

TableCell td1= new TableCell();
td1.CssClass = "TableCell1";

//or you can add it without a CssClass like this:
td.Height = "100px";
td1.Width = "100px";
td1.Style.Add("background-image", "url('image1.gif')");
 
G

Guest

Thanks Williams

Karl-Inge

Phillip Williams said:
You can use the cssClass attribute, e.g.

.TableCell1
{
background-image:url("images/Image1.gif");
}

and in your C# code:

TableCell td1= new TableCell();
td1.CssClass = "TableCell1";

//or you can add it without a CssClass like this:
td.Height = "100px";
td1.Width = "100px";
td1.Style.Add("background-image", "url('image1.gif')");
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
 
G

Guest

Hi Phillips

Your suggestion help me in the right directions, but I have still problem.
I’m trying to make a tab style horizontal menu similar to that you use on top
of your web http://www.webswapp.com.

Do you have an example?

Karl-Inge
 
G

Guest

Hi Karl-Inge,

In displaying menu items on my website, I use a Button server control whose
cssClass is set with a background image that gives that impression of a Tab
(without the rectangular edges). The button has both the onmouseout and
onmouseover events changing the cssClass (which in turn displays a different
background image to the button).
 
G

Guest

Hi Phillip

Thanks for your help.

I can now change the buttons style with onmouseover and onmouseout.
My next problem is how I can reach a CSharp script when click the button.


Karl-Inge
 
Ad

Advertisements

G

Guest

You must have used an HtmlInputButton <input type="button"> object. If you
had used a Button server control it would have equally worked with the
Button.Click event, e..g

<asp:Button OnClick="ServerFunction"
onmouseover="this.className='something';"
onmouseout="this.className='somethingelse';" Text="Menu1"
runat="sever"></asp:Button>
 
G

Guest

Thank you Phillip

Yes, I used HthmlInputButton with runat=server, and that work fin.

Your suggestion work, but IntelliSense don’t give me the choose
“onmouseover, onmouseout†and I cant find information in Visual studio 2005
documentation that asp:button support this events?

Is it some basic information I have missed?

Karl-Inge Reknes
 
Ad

Advertisements

G

Guest

Hi Karl-Inge,

No, it is not exactly basic information that you missed; rather it is
programming knowledge that you would have acquired had you worked with DHTML
before the ASP.NET server controls had come along. :)

ASP.NET server controls are very excellent creatures in allowing programmers
powerful interfaces without having to learn all of the details of the HTML
objects that they render. The onmouseover and onmouseout attributes could
have been done in a more elegant manner without having the intellisense
complaining about them like this in the codebehind (e.g. during the Page
PreRender event handling):

Button1.Attributes.Add("onmouseover", "this.className='class1';")
Button2.Attributes.Add("onmouseout", "this.className='class2';")
 
Ad

Advertisements


Top