473,382 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

programatically setting the background property of a <td>

Gil
Hello,

I use VB.NET and have a series of linkbuttons that are inside individual
<td>s. Like this:

<td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td>

I would like the background of the td to be different for the currently
selected linkbutton than for the other linkbuttons:

<td background="image1.gif"><asp:linkbutton id="myID1" runat="server"/> </td>
<td background="image2.gif"><asp:linkbutton id="myID2" runat="server"/></td>
<td background="image2.gif"><asp:linkbutton id="myID3" runat="server"/></td>
I tried several things before posting. First I tried to create a
<asp:literal/> and refer to that literal in by aspx.vb file. Thus I wanted
to programatically specify the image that would be displayed in the
background of my <td>:

If ...then
myLiteral = "<td background='image1.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

else
myLiteral = "<td background='image2.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

end if
This suffers from the problem that I can't refer to a linkbutton in my
literal without first having a tag appear in the html part of the .aspx code,
since the tag needs to be inside the <td>. See "Linkbutton Constructor" in
the .net framework class library.

Next I tried to do it by placing my linkbutton in the html portion of the
..aspx file by placing it inside a <asp:table>:

<asp:table>
<asp:tablerow>
<asp:tablecell>
<asp:linkbutton id=...>
</asp:tablecell>
</asp:tablerow>
</asp:table>

My hope was that I could then programatically specify the property of
<asp:tablecell>. This too suffered from the problem that my linkbutton could
not be contained in this <asp:table> arrangement.

Any help is sure appreaciated.
Thanks,
Gil
Jul 21 '05 #1
3 4801
Hi,

If you put your linkbuttons into the DataGrid and make some changes on
ItemDataBound evebt you can change the selected linkbtton background. You can
bind linkbutton's text on DataGrid's ItemDataBound event also.You can change
cell's background when cell is clicked or double clicked. If you can't make
this, I will send the detail sample code later.

Have a nice work,

"Gil" wrote:
Hello,

I use VB.NET and have a series of linkbuttons that are inside individual
<td>s. Like this:

<td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td>

I would like the background of the td to be different for the currently
selected linkbutton than for the other linkbuttons:

<td background="image1.gif"><asp:linkbutton id="myID1" runat="server"/> </td>
<td background="image2.gif"><asp:linkbutton id="myID2" runat="server"/></td>
<td background="image2.gif"><asp:linkbutton id="myID3" runat="server"/></td>
I tried several things before posting. First I tried to create a
<asp:literal/> and refer to that literal in by aspx.vb file. Thus I wanted
to programatically specify the image that would be displayed in the
background of my <td>:

If ...then
myLiteral = "<td background='image1.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

else
myLiteral = "<td background='image2.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

end if
This suffers from the problem that I can't refer to a linkbutton in my
literal without first having a tag appear in the html part of the .aspx code,
since the tag needs to be inside the <td>. See "Linkbutton Constructor" in
the .net framework class library.

Next I tried to do it by placing my linkbutton in the html portion of the
.aspx file by placing it inside a <asp:table>:

<asp:table>
<asp:tablerow>
<asp:tablecell>
<asp:linkbutton id=...>
</asp:tablecell>
</asp:tablerow>
</asp:table>

My hope was that I could then programatically specify the property of
<asp:tablecell>. This too suffered from the problem that my linkbutton could
not be contained in this <asp:table> arrangement.

Any help is sure appreaciated.
Thanks,
Gil

Jul 21 '05 #2
Gil
Hi Aytac,

Thanks for the reply. Can you post the sample code.

Thanks again.
Gil

"Aytaç ÖZAY" wrote:
Hi,

If you put your linkbuttons into the DataGrid and make some changes on
ItemDataBound evebt you can change the selected linkbtton background. You can
bind linkbutton's text on DataGrid's ItemDataBound event also.You can change
cell's background when cell is clicked or double clicked. If you can't make
this, I will send the detail sample code later.

Have a nice work,

"Gil" wrote:
Hello,

I use VB.NET and have a series of linkbuttons that are inside individual
<td>s. Like this:

<td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td>

I would like the background of the td to be different for the currently
selected linkbutton than for the other linkbuttons:

<td background="image1.gif"><asp:linkbutton id="myID1" runat="server"/> </td>
<td background="image2.gif"><asp:linkbutton id="myID2" runat="server"/></td>
<td background="image2.gif"><asp:linkbutton id="myID3" runat="server"/></td>
I tried several things before posting. First I tried to create a
<asp:literal/> and refer to that literal in by aspx.vb file. Thus I wanted
to programatically specify the image that would be displayed in the
background of my <td>:

If ...then
myLiteral = "<td background='image1.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

else
myLiteral = "<td background='image2.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

end if
This suffers from the problem that I can't refer to a linkbutton in my
literal without first having a tag appear in the html part of the .aspx code,
since the tag needs to be inside the <td>. See "Linkbutton Constructor" in
the .net framework class library.

Next I tried to do it by placing my linkbutton in the html portion of the
.aspx file by placing it inside a <asp:table>:

<asp:table>
<asp:tablerow>
<asp:tablecell>
<asp:linkbutton id=...>
</asp:tablecell>
</asp:tablerow>
</asp:table>

My hope was that I could then programatically specify the property of
<asp:tablecell>. This too suffered from the problem that my linkbutton could
not be contained in this <asp:table> arrangement.

Any help is sure appreaciated.
Thanks,
Gil

Jul 21 '05 #3
Hi Gill,

First of all sorry for response back late:( It's the code under, that you want

The first method is used with DataGrid's ItemCommand event, if u want to use
ItemCommand event, u will write the changeCellcolor code in this method.

The second code is used with DataGrid's ItemDataBound event, if u want to
use this method u don't need to wite anything in it.

private void dgGenel_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "update") {
// Set editable list item index if "update" button clicked next to the
item
dgGenel.EditItemIndex = e.Item.ItemIndex;
int dgID=-1;
dgID = (int)dgGenel.DataKeys[e.Item.ItemIndex];
Response.Redirect(Request.Url.ToString()+"&updateI D="+dgID);
}
}

private void dgGenel_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex == -1)
return;

int dgID=-1;
dgID = (int)dgGenel.DataKeys[e.Item.ItemIndex];

e.Item.Attributes.Add("OnDblClick", "window.location='" +
"http://"+Request.Url.Host+Request.Url.AbsolutePath+"?upda teID="+dgID+"'");

if (dgID == updateID)
e.Item.BackColor = Color.FromArgb(255, 255, 204);
else
{
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='#BDD3FB';this.style.c ursor='hand'");
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='White'");
e.Item.BackColor = Color.White;
}
}

Have a nice day,

"Gil" wrote:
Hi Aytac,

Thanks for the reply. Can you post the sample code.

Thanks again.
Gil

"Aytaç ÖZAY" wrote:
Hi,

If you put your linkbuttons into the DataGrid and make some changes on
ItemDataBound evebt you can change the selected linkbtton background. You can
bind linkbutton's text on DataGrid's ItemDataBound event also.You can change
cell's background when cell is clicked or double clicked. If you can't make
this, I will send the detail sample code later.

Have a nice work,

"Gil" wrote:
Hello,

I use VB.NET and have a series of linkbuttons that are inside individual
<td>s. Like this:

<td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td>

I would like the background of the td to be different for the currently
selected linkbutton than for the other linkbuttons:

<td background="image1.gif"><asp:linkbutton id="myID1" runat="server"/> </td>
<td background="image2.gif"><asp:linkbutton id="myID2" runat="server"/></td>
<td background="image2.gif"><asp:linkbutton id="myID3" runat="server"/></td>
I tried several things before posting. First I tried to create a
<asp:literal/> and refer to that literal in by aspx.vb file. Thus I wanted
to programatically specify the image that would be displayed in the
background of my <td>:

If ...then
myLiteral = "<td background='image1.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

else
myLiteral = "<td background='image2.gif'><asp:linkbutton id='myID'
runat='server'/> </td>"

end if
This suffers from the problem that I can't refer to a linkbutton in my
literal without first having a tag appear in the html part of the .aspx code,
since the tag needs to be inside the <td>. See "Linkbutton Constructor" in
the .net framework class library.

Next I tried to do it by placing my linkbutton in the html portion of the
.aspx file by placing it inside a <asp:table>:

<asp:table>
<asp:tablerow>
<asp:tablecell>
<asp:linkbutton id=...>
</asp:tablecell>
</asp:tablerow>
</asp:table>

My hope was that I could then programatically specify the property of
<asp:tablecell>. This too suffered from the problem that my linkbutton could
not be contained in this <asp:table> arrangement.

Any help is sure appreaciated.
Thanks,
Gil

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MyndPhlyp | last post by:
I've been busting my head trying to figure this out for quite some time. With IE6 and NS7, no problems. I can simply code the HTML <img height="100%"> and be done with it. But NS4 and NS6 (and...
0
by: Matt Adams | last post by:
I want to move the following <PRE> defintion to a css file: <TABLE><TR><TD><PRE>sample text</PRE></TD> <TD> not predefined font</TD></TR></TABLE> should be <TABLE><TR><TD class=aaa>sample...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
3
by: RC | last post by:
I have a very sime html table like <html><head><title>My Table</title> <style> input { margin: 0; padding: 0; border-width: 0; text-indet: 0; text-align: left } </style></head><body> <table...
3
by: Henry Johnson | last post by:
Okay - I'm spinning my wheels on this one... can someone help me figure out how to programmatically populate a table cell as follows (from C# code-behind)? I've tried using a Literal control in the...
3
by: Gil | last post by:
Hello, I use VB.NET and have a series of linkbuttons that are inside individual <td>s. Like this: <td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td> I would like...
5
by: mahesr | last post by:
I want to match some particular text between <tr>and </tr> or <td>and </td>.... in PHP. like below............ <table><tr> CATEGORY: <td><font face="Verdana" size="1" color="#A000A0"> Wedding...
4
George Lft
by: George Lft | last post by:
I'm new at building table. Mostly PHP programming . Now I can't seem to fix the size of my table row and column. Any idea? <h4>Two rows and three columns:</h4> <table border="1"> <tr> ...
7
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.