473,513 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Putting a hyperlink in a Calendar Control

This does not work...
Private Sub calWO_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles calWO.DayRender
If e.Day.Date.Day = 18 Then
Dim myControl As New LiteralControl("<a
href='http://www.google.com'></a>")
e.Cell.Controls.Add(myControl)
End If
End Sub

Anyone know why not?
Thanks,
T
Feb 23 '06 #1
2 2348
Jon
Hello Tina.

I'd suggest using a HTMLGenericControl rather than a literal.

This is a c# version i use, it may help:

//the function to render the days of the calendar as specified by us
private void Calendar1_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
//clear the controls that are rendered automatically
//by the calendar control

e.Cell.Controls.Clear();

//Create a new link control
System.Web.UI.HtmlControls.HtmlGenericControl Link = new
System.Web.UI.HtmlControls.HtmlGenericControl();

Link.TagName = "a";
Link.InnerText = e.Day.DayNumberText;

//set the href value to the javascript function to select the date
Link.Attributes.Add("href", "javascript:SelectDate('" +
e.Day.Date.ToString("d") + "');");

//set the color of the link
Link.Attributes.Add("style", "color:#000000;");

//add our link control to the day
e.Cell.Controls.Add(Link);
}

"Tina" wrote:
This does not work...
Private Sub calWO_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles calWO.DayRender
If e.Day.Date.Day = 18 Then
Dim myControl As New LiteralControl("<a
href='http://www.google.com'></a>")
e.Cell.Controls.Add(myControl)
End If
End Sub

Anyone know why not?
Thanks,
T

Feb 23 '06 #2
odd but I found that very same code snippet at dotpitchstudios.com.

I can't seem to convert....

Link.Attributes.Add("href", "javascript:SelectDate('" +
e.Day.Date.ToString("d") + "');");

to VB that will not get an error.
T

"Jon" <Jo*@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
Hello Tina.

I'd suggest using a HTMLGenericControl rather than a literal.

This is a c# version i use, it may help:

//the function to render the days of the calendar as specified by us
private void Calendar1_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
//clear the controls that are rendered automatically
//by the calendar control

e.Cell.Controls.Clear();

//Create a new link control
System.Web.UI.HtmlControls.HtmlGenericControl Link = new
System.Web.UI.HtmlControls.HtmlGenericControl();

Link.TagName = "a";
Link.InnerText = e.Day.DayNumberText;

//set the href value to the javascript function to select the date
Link.Attributes.Add("href", "javascript:SelectDate('" +
e.Day.Date.ToString("d") + "');");

//set the color of the link
Link.Attributes.Add("style", "color:#000000;");

//add our link control to the day
e.Cell.Controls.Add(Link);
}

"Tina" wrote:
This does not work...
Private Sub calWO_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles calWO.DayRender
If e.Day.Date.Day = 18 Then
Dim myControl As New LiteralControl("<a
href='http://www.google.com'></a>")
e.Cell.Controls.Add(myControl)
End If
End Sub

Anyone know why not?
Thanks,
T

Feb 24 '06 #3

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

Similar topics

2
3143
by: Billy | last post by:
I want to make a calendar and add a hyperlink to the days inside the calendar. The source code is below: <body> <SCRIPT LANGUAGE="JavaScript"> var now = new Date();
5
4590
by: Miguel Dias Moura | last post by:
Hello, i am trying to create a .css file with several styles and apply them to the calendar control so i can change the look of: 1. Text Type and Format (Bold, Underline, etc) 2. Background...
1
1483
by: VB Programmer | last post by:
Any ideas/examples of this... Insert appointment entries into a calendar from a db (like outlook) and you can click on it (it will be a hyperlink to a "detailed view" page). I'm more interested...
2
3401
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
4
5784
by: wrytat | last post by:
I have a form with a textbox for the user to enter a quantity and another textbox for the delivery date. I disabled this delivery date textbox such that the user has to press a calendar link next...
3
2706
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
20
2973
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is...
5
8787
LAD
by: LAD | last post by:
Using Access 2003 on Windows 2000. My Skill Level: Med Low (Some VBA, okay with Access) Form: Single View - based on Query of single Table to sort by field. Application: Dealers email 'contract...
9
2023
by: RobertTheProgrammer | last post by:
Hi folks, I've been struggling with this for a few hours and I'm hoping someone can help me out. On my GridView (with C# codebehind) I have a date entry field. To help users enter only valid...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.