Gang, using the dayrender event I'd like to cast the hyperlink that displays the day to a linkbutton or some type of aspx control to where I can apply some custom javascript to it. For the life of me I can't figure out how to do this. Cast, CType, DirectCast don't work. The control renders itself as a <a href></a> literal control . Any tips on an approach?
Calender control - how to get the day hyperlink
Collapse
X
-
Tags: None
-
I'm not at my machine now but a code example is something like
Code:DIm lb as LinkButton = CType(e.cell.Controls(0),LinkButton)
Anyway, as a solution, I decided to simply clear the controls in the cells, then dynamically create my own linkbuttons. I would prefer to avoid this if I could only because it creates a little more overhead on the postback.Comment
-
Thanks, the control exists at index 0. the problem is that there is no way to cast the control to some type of aspx type in order to apply custom attributes to it.Comment
-
yes, e.day.date is there so the solution I have settled on is to just clear out the controls in each day cell then instantiate a new linkbutton using that date. It would be nice to avoid that route simply to keep the overhead down. asp.net as we know is pretty resource heavy in general. It is what it is : )Comment
-
You might have to overwrite the controls...
Or you could look into a JavaScript solution that attaches a click event to the "day" since there is an HTML element with an ID for the "day". Unless you meant to say "no, there is no ID associated with the Day".
-FrinnyComment
-
I want to add custom javascript to the existing day hyperlink so that onmouseover I can identify that it is truly a click on that hyperlink as opposed to a click on the larger day-cell (I am firing a different event on the cell click).Comment
-
Ok, write a JavaScript function that retrieves all of the hyperlinks within your calendar.
I believe the calendar is rendered as a table right?
The table should have an ID and you can use the document.getEle mentByID() method to retrieve it. Once you have the table, you can use tableVariable.g etElementsByTag Name() to retrieve all of the hyperlinks within the table.
You can then loop through the hyperlinks and attach a click event to them so that you can set a hidden variable or something in order to indicate that it was the hyperlink clicked, as opposed to the cell.
-FrinnyComment
-
Comment