468,289 Members | 1,853 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,289 developers. It's quick & easy.

inserting args into a DataList's <td> tag

I would like to have DHTML on my DataList so that when I hover over a cell,
it will change colors. I can't find a way to get onMouseOver into the
generated <td> from a DataList. There must be way to do this.... I am just
missing it I suppose.

Anyone know?

Thanks,
Steve
Nov 18 '05 #1
7 1206
I'm just guessing here (because I haven't tried it myself) but you might try
handling the ItemCreated event and processing it there... Something like
this:

Protected Sub myDataList_ItemCreated(sender as object, e as eventargs)
handles myDataList.ItemCreated
If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
dim myItem as DataListItem = CType(e.Item, DataListItem)
myItem.Attributes("onMouseOver") = "javascript:none;"
End If
End Sub

Keep in mind that I just typed this in my news client and not in the IDE, so
its not guaranteed to work, but it may give you some ideas.
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I would like to have DHTML on my DataList so that when I hover over a cell, it will change colors. I can't find a way to get onMouseOver into the
generated <td> from a DataList. There must be way to do this.... I am just missing it I suppose.

Anyone know?

Thanks,
Steve

Nov 18 '05 #2
Hi Chris,

Thanks for the reply.

Yeah, I found that I can use Attributes.Add() to do what I want. Weird
thing is... I have implemented it, but in the result HTML the attributes
aren't there. I've checked my schema, it's IE 5, so it's not that.

I've set a breakpoint in the DataBind event to see if it is actually firing,
it is. I have added this code to add the attributes. I suspect that my
DHTML syntax is off, but I should at least see the bad syntax in the result
HTML, but it's not there.
e.Item.Attributes.Add("onMouseEnter", "style.color = 'red'");

Any ideas?
"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:Ox*************@tk2msftngp13.phx.gbl...
I'm just guessing here (because I haven't tried it myself) but you might try handling the ItemCreated event and processing it there... Something like
this:

Protected Sub myDataList_ItemCreated(sender as object, e as eventargs)
handles myDataList.ItemCreated
If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
dim myItem as DataListItem = CType(e.Item, DataListItem)
myItem.Attributes("onMouseOver") = "javascript:none;"
End If
End Sub

Keep in mind that I just typed this in my news client and not in the IDE, so its not guaranteed to work, but it may give you some ideas.
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I would like to have DHTML on my DataList so that when I hover over a

cell,
it will change colors. I can't find a way to get onMouseOver into the
generated <td> from a DataList. There must be way to do this.... I am

just
missing it I suppose.

Anyone know?

Thanks,
Steve


Nov 18 '05 #3
Hmm... Sounds like it should work. I don't know why it would make a
difference, but try not doing the .Add and just accessing the
AttributesCollection directly:
e.Item.Attributes("onMouseEnter","style.color = 'red'");
"Steve Klett" <sk************@yahoo.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
Hi Chris,

Thanks for the reply.

Yeah, I found that I can use Attributes.Add() to do what I want. Weird
thing is... I have implemented it, but in the result HTML the attributes
aren't there. I've checked my schema, it's IE 5, so it's not that.

I've set a breakpoint in the DataBind event to see if it is actually firing, it is. I have added this code to add the attributes. I suspect that my
DHTML syntax is off, but I should at least see the bad syntax in the result HTML, but it's not there.
e.Item.Attributes.Add("onMouseEnter", "style.color = 'red'");

Any ideas?
"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:Ox*************@tk2msftngp13.phx.gbl...
I'm just guessing here (because I haven't tried it myself) but you might try
handling the ItemCreated event and processing it there... Something like
this:

Protected Sub myDataList_ItemCreated(sender as object, e as eventargs)
handles myDataList.ItemCreated
If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
dim myItem as DataListItem = CType(e.Item, DataListItem)
myItem.Attributes("onMouseOver") = "javascript:none;"
End If
End Sub

Keep in mind that I just typed this in my news client and not in the IDE, so
its not guaranteed to work, but it may give you some ideas.
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I would like to have DHTML on my DataList so that when I hover over a

cell,
it will change colors. I can't find a way to get onMouseOver into the
generated <td> from a DataList. There must be way to do this.... I

am just
missing it I suppose.

Anyone know?

Thanks,
Steve



Nov 18 '05 #4
That doesn't work either. This is odd. I don't see what I could be
missing.....

"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Hmm... Sounds like it should work. I don't know why it would make a
difference, but try not doing the .Add and just accessing the
AttributesCollection directly:
e.Item.Attributes("onMouseEnter","style.color = 'red'");
"Steve Klett" <sk************@yahoo.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
Hi Chris,

Thanks for the reply.

Yeah, I found that I can use Attributes.Add() to do what I want. Weird
thing is... I have implemented it, but in the result HTML the attributes
aren't there. I've checked my schema, it's IE 5, so it's not that.

I've set a breakpoint in the DataBind event to see if it is actually

firing,
it is. I have added this code to add the attributes. I suspect that my
DHTML syntax is off, but I should at least see the bad syntax in the

result
HTML, but it's not there.
e.Item.Attributes.Add("onMouseEnter", "style.color = 'red'");

Any ideas?
"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:Ox*************@tk2msftngp13.phx.gbl...
I'm just guessing here (because I haven't tried it myself) but you might
try
handling the ItemCreated event and processing it there... Something
like this:

Protected Sub myDataList_ItemCreated(sender as object, e as eventargs)
handles myDataList.ItemCreated
If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
dim myItem as DataListItem = CType(e.Item, DataListItem)
myItem.Attributes("onMouseOver") = "javascript:none;"
End If
End Sub

Keep in mind that I just typed this in my news client and not in the

IDE,
so
its not guaranteed to work, but it may give you some ideas.
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> I would like to have DHTML on my DataList so that when I hover over a cell,
> it will change colors. I can't find a way to get onMouseOver into the > generated <td> from a DataList. There must be way to do this.... I

am just
> missing it I suppose.
>
> Anyone know?
>
> Thanks,
> Steve
>
>



Nov 18 '05 #5
If I use a dataGrid, it works fine. I think with a DataList you can't
access the cell.... DataGrid exposes cells collection, then you can do it,
but not the DataList
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
That doesn't work either. This is odd. I don't see what I could be
missing.....

"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Hmm... Sounds like it should work. I don't know why it would make a
difference, but try not doing the .Add and just accessing the
AttributesCollection directly:
e.Item.Attributes("onMouseEnter","style.color = 'red'");
"Steve Klett" <sk************@yahoo.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
Hi Chris,

Thanks for the reply.

Yeah, I found that I can use Attributes.Add() to do what I want. Weird thing is... I have implemented it, but in the result HTML the attributes aren't there. I've checked my schema, it's IE 5, so it's not that.

I've set a breakpoint in the DataBind event to see if it is actually firing,
it is. I have added this code to add the attributes. I suspect that my DHTML syntax is off, but I should at least see the bad syntax in the

result
HTML, but it's not there.
e.Item.Attributes.Add("onMouseEnter", "style.color = 'red'");

Any ideas?
"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:Ox*************@tk2msftngp13.phx.gbl...
> I'm just guessing here (because I haven't tried it myself) but you might try
> handling the ItemCreated event and processing it there... Something like > this:
>
> Protected Sub myDataList_ItemCreated(sender as object, e as eventargs) > handles myDataList.ItemCreated
> If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
> dim myItem as DataListItem = CType(e.Item, DataListItem)
> myItem.Attributes("onMouseOver") = "javascript:none;"
> End If
> End Sub
>
> Keep in mind that I just typed this in my news client and not in the

IDE,
so
> its not guaranteed to work, but it may give you some ideas.
>
>
> "Steve Klett" <sk************@yahoo.com> wrote in message
> news:%2****************@TK2MSFTNGP09.phx.gbl...
> > I would like to have DHTML on my DataList so that when I hover
over a > cell,
> > it will change colors. I can't find a way to get onMouseOver into the > > generated <td> from a DataList. There must be way to do this....
I am
> just
> > missing it I suppose.
> >
> > Anyone know?
> >
> > Thanks,
> > Steve
> >
> >
>
>



Nov 18 '05 #6
Ahh, that makes sense. Odd though. Anyone from MS care to comment on why
that is?

"Steve Klett" <sk************@yahoo.com> wrote in message
news:Oi**************@TK2MSFTNGP12.phx.gbl...
If I use a dataGrid, it works fine. I think with a DataList you can't
access the cell.... DataGrid exposes cells collection, then you can do it, but not the DataList
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
That doesn't work either. This is odd. I don't see what I could be
missing.....

"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Hmm... Sounds like it should work. I don't know why it would make a
difference, but try not doing the .Add and just accessing the
AttributesCollection directly:
e.Item.Attributes("onMouseEnter","style.color = 'red'");
"Steve Klett" <sk************@yahoo.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
> Hi Chris,
>
> Thanks for the reply.
>
> Yeah, I found that I can use Attributes.Add() to do what I want. Weird > thing is... I have implemented it, but in the result HTML the attributes > aren't there. I've checked my schema, it's IE 5, so it's not that.
>
> I've set a breakpoint in the DataBind event to see if it is actually
firing,
> it is. I have added this code to add the attributes. I suspect that
my
> DHTML syntax is off, but I should at least see the bad syntax in the
result
> HTML, but it's not there.
> e.Item.Attributes.Add("onMouseEnter", "style.color = 'red'");
>
>
>
> Any ideas?
> "Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
> news:Ox*************@tk2msftngp13.phx.gbl...
> > I'm just guessing here (because I haven't tried it myself) but you might
> try
> > handling the ItemCreated event and processing it there...
Something
like
> > this:
> >
> > Protected Sub myDataList_ItemCreated(sender as object, e as eventargs) > > handles myDataList.ItemCreated
> > If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
> > dim myItem as DataListItem = CType(e.Item, DataListItem)
> > myItem.Attributes("onMouseOver") = "javascript:none;"
> > End If
> > End Sub
> >
> > Keep in mind that I just typed this in my news client and not in
the IDE,
> so
> > its not guaranteed to work, but it may give you some ideas.
> >
> >
> > "Steve Klett" <sk************@yahoo.com> wrote in message
> > news:%2****************@TK2MSFTNGP09.phx.gbl...
> > > I would like to have DHTML on my DataList so that when I hover

over
a
> > cell,
> > > it will change colors. I can't find a way to get onMouseOver

into the
> > > generated <td> from a DataList. There must be way to do

this.... I am
> > just
> > > missing it I suppose.
> > >
> > > Anyone know?
> > >
> > > Thanks,
> > > Steve
> > >
> > >
> >
> >
>
>



Nov 18 '05 #7
I did this just to see if anything weird popped up
e.Item.Attributes.Add("onMouseEnter", "javascript:alert('test');");

IEnumerator iT = e.Item.Attributes.Keys.GetEnumerator();

while(iT.MoveNext())

{

Response.Write((string)iT.Current);

}
sure enough, the attributes are being added, just not rendered. Bummer.
Yeah, MS.. any word, suggestions, work arounds?

"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
Ahh, that makes sense. Odd though. Anyone from MS care to comment on why
that is?

"Steve Klett" <sk************@yahoo.com> wrote in message
news:Oi**************@TK2MSFTNGP12.phx.gbl...
If I use a dataGrid, it works fine. I think with a DataList you can't
access the cell.... DataGrid exposes cells collection, then you can do

it,
but not the DataList
"Steve Klett" <sk************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
That doesn't work either. This is odd. I don't see what I could be
missing.....

"Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
> Hmm... Sounds like it should work. I don't know why it would make a
> difference, but try not doing the .Add and just accessing the
> AttributesCollection directly:
> e.Item.Attributes("onMouseEnter","style.color = 'red'");
>
>
> "Steve Klett" <sk************@yahoo.com> wrote in message
> news:Of**************@TK2MSFTNGP11.phx.gbl...
> > Hi Chris,
> >
> > Thanks for the reply.
> >
> > Yeah, I found that I can use Attributes.Add() to do what I want.

Weird
> > thing is... I have implemented it, but in the result HTML the

attributes
> > aren't there. I've checked my schema, it's IE 5, so it's not that. > >
> > I've set a breakpoint in the DataBind event to see if it is actually > firing,
> > it is. I have added this code to add the attributes. I suspect that
my
> > DHTML syntax is off, but I should at least see the bad syntax in the > result
> > HTML, but it's not there.
> > e.Item.Attributes.Add("onMouseEnter", "style.color = 'red'");
> >
> >
> >
> > Any ideas?
> > "Chris Bower" <ch***********@SPAMunionfedbank.com> wrote in message > > news:Ox*************@tk2msftngp13.phx.gbl...
> > > I'm just guessing here (because I haven't tried it myself) but you might
> > try
> > > handling the ItemCreated event and processing it there...

Something like
> > > this:
> > >
> > > Protected Sub myDataList_ItemCreated(sender as object, e as

eventargs)
> > > handles myDataList.ItemCreated
> > > If e.Item.Type = Item or e.Item.Type = AlternatingItem Then
> > > dim myItem as DataListItem = CType(e.Item, DataListItem)
> > > myItem.Attributes("onMouseOver") = "javascript:none;"
> > > End If
> > > End Sub
> > >
> > > Keep in mind that I just typed this in my news client and not in the > IDE,
> > so
> > > its not guaranteed to work, but it may give you some ideas.
> > >
> > >
> > > "Steve Klett" <sk************@yahoo.com> wrote in message
> > > news:%2****************@TK2MSFTNGP09.phx.gbl...
> > > > I would like to have DHTML on my DataList so that when I hover

over
a
> > > cell,
> > > > it will change colors. I can't find a way to get onMouseOver into the
> > > > generated <td> from a DataList. There must be way to do

this....
I
> am
> > > just
> > > > missing it I suppose.
> > > >
> > > > Anyone know?
> > > >
> > > > Thanks,
> > > > Steve
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by bissatch | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.