|
|
|
start date: Mon, 13 Aug 2007 08:26:51 -0400,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Mufasa
|
|
2
Mark Rae [MVP]
|
|
3
Mufasa
|
|
4
John Mott
|
|
5
Homer J. Simpson
|
|
6
John Mott
|
|
7
Mufasa
|
|
8
Homer J. Simpson
|
Making an entire cell of a table respond to a click.
I have cell that I want to be able to have the user click the cell anywhere
and it will link to somewhere else. I want to use a cell because I want it
to be 25% of the width of the screen ( I have 4 'buttons' to do this.) I
don't want to use a graphic because I want it to be able to resize.
Any suggestions?
In a perfect world, I'd also like to have it change color when somebody goes
over it.
TIA - Jeff.
Date:Mon, 13 Aug 2007 08:26:51 -0400
Author:
|
Re: Making an entire cell of a table respond to a click.
"Mufasa" wrote in message
news:O0eS0Sa3HHA.5164@TK2MSFTNGP05.phx.gbl...
>I have cell that I want to be able to have the user click the cell anywhere
>and it will link to somewhere else. I want to use a cell because I want it
>to be 25% of the width of the screen ( I have 4 'buttons' to do this.) I
>don't want to use a graphic because I want it to be able to resize.
>
> Any suggestions?
>
> In a perfect world, I'd also like to have it change color when somebody
> goes over it.
<td style="cursor:pointer;" onclick="location.href='page2.aspx';"
onmouseover="this.style.backgroundColor='Green';"
onmouseout="this.style.backgroundColor='White';">
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Mon, 13 Aug 2007 13:48:04 +0100
Author:
|
Re: Making an entire cell of a table respond to a click.
That works great!
Is there anyway to automate it into a CSS or some othere way so I don't have
to do it every single time?
TIA - Jeff.
"Mark Rae [MVP]" wrote in message
news:ew9woga3HHA.4584@TK2MSFTNGP03.phx.gbl...
> "Mufasa" wrote in message
> news:O0eS0Sa3HHA.5164@TK2MSFTNGP05.phx.gbl...
>>I have cell that I want to be able to have the user click the cell
>>anywhere and it will link to somewhere else. I want to use a cell because
>>I want it to be 25% of the width of the screen ( I have 4 'buttons' to do
>>this.) I don't want to use a graphic because I want it to be able to
>>resize.
>>
>> Any suggestions?
>>
>> In a perfect world, I'd also like to have it change color when somebody
>> goes over it.
>
>
> <td style="cursor:pointer;" onclick="location.href='page2.aspx';"
> onmouseover="this.style.backgroundColor='Green';"
> onmouseout="this.style.backgroundColor='White';">
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
Date:Mon, 13 Aug 2007 09:22:23 -0400
Author:
|
Re: Making an entire cell of a table respond to a click.
> <td style="cursor:pointer;" onclick="location.href='page2.aspx';"
> onmouseover="this.style.backgroundColor='Green';"
> onmouseout="this.style.backgroundColor='White';">
So that's how you do this sort of thing in ASP.NET 2.0, huh? Looks an awful
lot like plain old HTML to me.
How do you go about implementing this sort of thing "cleanly" for server
controls that ultimately generate tables, such as a calendar or gridview?
Date:Mon, 13 Aug 2007 10:48:58 -0400
Author:
|
Re: Making an entire cell of a table respond to a click.
You can only put styles (the cursor in this case) in css, the events
(onmouseover, onmouseout, onclick) must appear in a tag somewhere. The
location change is a javascript so it can't go in a style sheet either.
However, you can put the different styles into a css class and do this:
<style>
..overClass {background-color: Green}
..outClass {background-color:White}
</style>
<td onmouseover="this.className='overClass'"
onmouseout='this.className='outClass'> content </td>
John
nice clean examples at www.nicecleanexample.com
"Mufasa" wrote in message
news:OW361xa3HHA.5164@TK2MSFTNGP05.phx.gbl...
> That works great!
>
> Is there anyway to automate it into a CSS or some othere way so I don't
> have to do it every single time?
>
> TIA - Jeff.
>
> "Mark Rae [MVP]" wrote in message
> news:ew9woga3HHA.4584@TK2MSFTNGP03.phx.gbl...
>> "Mufasa" wrote in message
>> news:O0eS0Sa3HHA.5164@TK2MSFTNGP05.phx.gbl...
>>>I have cell that I want to be able to have the user click the cell
>>>anywhere and it will link to somewhere else. I want to use a cell because
>>>I want it to be 25% of the width of the screen ( I have 4 'buttons' to do
>>>this.) I don't want to use a graphic because I want it to be able to
>>>resize.
>>>
>>> Any suggestions?
>>>
>>> In a perfect world, I'd also like to have it change color when somebody
>>> goes over it.
>>
>>
>> <td style="cursor:pointer;" onclick="location.href='page2.aspx';"
>> onmouseover="this.style.backgroundColor='Green';"
>> onmouseout="this.style.backgroundColor='White';">
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net
>
>
Date:Mon, 13 Aug 2007 17:09:09 -0500
Author:
|
Re: Making an entire cell of a table respond to a click.
When generating table cells on the server you'd set the appropriate
attributes, as in:
TableCell td = new TableCell();
td.Attributes.Add("onmouseover","this.style.backgroundColor='Green'");
John
nice clean examples at www.nicecleanexample.com
"Homer J. Simpson" wrote in message
news:ejrcckb3HHA.4880@TK2MSFTNGP03.phx.gbl...
>> <td style="cursor:pointer;" onclick="location.href='page2.aspx';"
>> onmouseover="this.style.backgroundColor='Green';"
>> onmouseout="this.style.backgroundColor='White';">
>
> So that's how you do this sort of thing in ASP.NET 2.0, huh? Looks an
> awful lot like plain old HTML to me.
>
> How do you go about implementing this sort of thing "cleanly" for server
> controls that ultimately generate tables, such as a calendar or gridview?
>
Date:Mon, 13 Aug 2007 17:11:52 -0500
Author:
|
Re: Making an entire cell of a table respond to a click.
Thanks for all the info.
Jeff.
"John Mott" wrote in message
news:e4lwfaf3HHA.1212@TK2MSFTNGP05.phx.gbl...
> When generating table cells on the server you'd set the appropriate
> attributes, as in:
>
> TableCell td = new TableCell();
> td.Attributes.Add("onmouseover","this.style.backgroundColor='Green'");
>
> John
> nice clean examples at www.nicecleanexample.com
>
>
> "Homer J. Simpson" wrote in message
> news:ejrcckb3HHA.4880@TK2MSFTNGP03.phx.gbl...
>>> <td style="cursor:pointer;" onclick="location.href='page2.aspx';"
>>> onmouseover="this.style.backgroundColor='Green';"
>>> onmouseout="this.style.backgroundColor='White';">
>>
>> So that's how you do this sort of thing in ASP.NET 2.0, huh? Looks an
>> awful lot like plain old HTML to me.
>>
>> How do you go about implementing this sort of thing "cleanly" for server
>> controls that ultimately generate tables, such as a calendar or gridview?
>>
>
>
Date:Tue, 14 Aug 2007 08:08:45 -0400
Author:
|
Re: Making an entire cell of a table respond to a click.
>>> <td style="cursor:pointer;" onclick="location.href='page2.aspx';"
>>> onmouseover="this.style.backgroundColor='Green';"
>>> onmouseout="this.style.backgroundColor='White';">
>>
>> So that's how you do this sort of thing in ASP.NET 2.0, huh? Looks an
>> awful lot like plain old HTML to me.
>>
>> How do you go about implementing this sort of thing "cleanly" for server
>> controls that ultimately generate tables, such as a calendar or gridview?
>
> When generating table cells on the server you'd set the appropriate
> attributes, as in:
>
> TableCell td = new TableCell();
> td.Attributes.Add("onmouseover","this.style.backgroundColor='Green'");
Yeah, that's obvious enough if you're building the controls yourself--but
the crux of my question had to do with server controls that don't easily
give you access to the individual rows or cells. How would you go about
implementing, for example, an onclick event for the month name in a calendar
control? As far as I can see, the calendar object doesn't have a member
mapped to that particular <td>, and looking at the raw HTML output, it has
no ID either.
So under those circumstances, is "the best way" to hook up an event to try
to locate the correct cell by its position in the control collection--which
makes your code highly susceptible to break?
Date:Tue, 14 Aug 2007 08:58:41 -0400
Author:
|
|
|