473,246 Members | 1,476 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,246 software developers and data experts.

dynamicly add link button to calendar cel

I am trying to add a link button to a calendar.
this is a simple example:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date = Now.Date Then
Dim lbtntemp As New LinkButton
lbtntemp.Text = "go here"
lbtntemp.ID = "thsLnk"
e.Cell.Controls.Add((lbtntemp))
End If
End Sub
3. issues
1. i do not have a link, only text
2. i want to pass parameter(s) withthe link
3. how can i add a <br> to the cell if i want to add multile items?

Thanks!!!
kes
Nov 19 '05 #1
4 4490
You should read the DayRender documentation:

Note Since the DayRender event is raised while the Calendar control is
being rendered, you cannot add a control that can also raise an event, such
as LinkButton. You can only add static controls, such as
System.Web.UI.LiteralControl, Label, Image, and HyperLink.

I guess you're stuck with using a <a href=....> and pass something in the
querystring..
AS for your <br> question, try:

e.Cell.Controls.Add(New LiteralControl("<br>"))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Kurt Schroeder" <Ku***********@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
I am trying to add a link button to a calendar.
this is a simple example:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date = Now.Date Then
Dim lbtntemp As New LinkButton
lbtntemp.Text = "go here"
lbtntemp.ID = "thsLnk"
e.Cell.Controls.Add((lbtntemp))
End If
End Sub
3. issues
1. i do not have a link, only text
2. i want to pass parameter(s) withthe link
3. how can i add a <br> to the cell if i want to add multile items?

Thanks!!!
kes

Nov 19 '05 #2
What works for me is to set the SelectionMode Property to "Day." At this
point .Net automatically converts the day number as a linkbutton, which you
can use to capture which day the user selects!

To do that you use the calendar's SelectionChanged event to capture the
SelectedDate property:
(This is from MSDN under the SelectedDate property topic)
Label1.Text = "The selected date is " &
Calendar1.SelectedDate.ToShortDateString()

Since you now have the date the user selected, you can do such things as
populate a datagrid with the different items that are on that day from a
database.

Hope this helps.
Richard
"Kurt Schroeder" wrote:
I am trying to add a link button to a calendar.
this is a simple example:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date = Now.Date Then
Dim lbtntemp As New LinkButton
lbtntemp.Text = "go here"
lbtntemp.ID = "thsLnk"
e.Cell.Controls.Add((lbtntemp))
End If
End Sub
3. issues
1. i do not have a link, only text
2. i want to pass parameter(s) withthe link
3. how can i add a <br> to the cell if i want to add multile items?

Thanks!!!
kes

Nov 19 '05 #3
here is an odd one. I was able to add alink button and it can post back here
is how:
If e.Day.Date = Now.Date Then

Dim lbtntemp As New LinkButton
lbtntemp.Text = "go here"
lbtntemp.ID = "thsLnk"
lbtntemp.CommandName = "ths One"
lbtntemp.CommandArgument = "1"
lbtntemp.Attributes("onClick") =
"javascript:__doPostBack('LinkButton1','2day') "

e.Cell.Controls.Add(lbtntemp)
Dim btnbx1 As New Button
btnbx1.ID = "mytxt"
btnbx1.Text = "go"
btnbx1.CommandArgument = "ths" & Now.Date
btnbx1.CommandName = "ok_GO"

e.Cell.Controls.Add(btnbx1)
' DataBind()

End If
the link did work. The button did also, but not the way i wanted. I'm still
working onthis do you want me, but made some progress.
do you want me to keep you posted?
thanks
kes
"Karl Seguin" wrote:
You should read the DayRender documentation:

Note Since the DayRender event is raised while the Calendar control is
being rendered, you cannot add a control that can also raise an event, such
as LinkButton. You can only add static controls, such as
System.Web.UI.LiteralControl, Label, Image, and HyperLink.

I guess you're stuck with using a <a href=....> and pass something in the
querystring..
AS for your <br> question, try:

e.Cell.Controls.Add(New LiteralControl("<br>"))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Kurt Schroeder" <Ku***********@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
I am trying to add a link button to a calendar.
this is a simple example:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date = Now.Date Then
Dim lbtntemp As New LinkButton
lbtntemp.Text = "go here"
lbtntemp.ID = "thsLnk"
e.Cell.Controls.Add((lbtntemp))
End If
End Sub
3. issues
1. i do not have a link, only text
2. i want to pass parameter(s) withthe link
3. how can i add a <br> to the cell if i want to add multile items?

Thanks!!!
kes


Nov 19 '05 #4
Kurt:
Posting updates is always helpful to others who run into the same problems
you do. It's a shame you need to go through that extra effort, but does
seem like the only way to get things going. You might benefit from using a
3rd party control other than the built-in calendar.

I've always liked the free EwolrdUI one:
http://www.eworldui.net/CustomContro...PopupDemo.aspx

though I don't know if it'll solve your problem any better...

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Kurt Schroeder" <Ku***********@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com...
here is an odd one. I was able to add alink button and it can post back
here
is how:
If e.Day.Date = Now.Date Then

Dim lbtntemp As New LinkButton
lbtntemp.Text = "go here"
lbtntemp.ID = "thsLnk"
lbtntemp.CommandName = "ths One"
lbtntemp.CommandArgument = "1"
lbtntemp.Attributes("onClick") =
"javascript:__doPostBack('LinkButton1','2day') "

e.Cell.Controls.Add(lbtntemp)
Dim btnbx1 As New Button
btnbx1.ID = "mytxt"
btnbx1.Text = "go"
btnbx1.CommandArgument = "ths" & Now.Date
btnbx1.CommandName = "ok_GO"

e.Cell.Controls.Add(btnbx1)
' DataBind()

End If
the link did work. The button did also, but not the way i wanted. I'm
still
working onthis do you want me, but made some progress.
do you want me to keep you posted?
thanks
kes
"Karl Seguin" wrote:
You should read the DayRender documentation:

Note Since the DayRender event is raised while the Calendar control is
being rendered, you cannot add a control that can also raise an event,
such
as LinkButton. You can only add static controls, such as
System.Web.UI.LiteralControl, Label, Image, and HyperLink.

I guess you're stuck with using a <a href=....> and pass something in the
querystring..
AS for your <br> question, try:

e.Cell.Controls.Add(New LiteralControl("<br>"))

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Kurt Schroeder" <Ku***********@discussions.microsoft.com> wrote in
message
news:0E**********************************@microsof t.com...
>I am trying to add a link button to a calendar.
> this is a simple example:
> Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DayRenderEventArgs) Handles
> Calendar1.DayRender
> If e.Day.Date = Now.Date Then
> Dim lbtntemp As New LinkButton
> lbtntemp.Text = "go here"
> lbtntemp.ID = "thsLnk"
> e.Cell.Controls.Add((lbtntemp))
> End If
> End Sub
> 3. issues
> 1. i do not have a link, only text
> 2. i want to pass parameter(s) withthe link
> 3. how can i add a <br> to the cell if i want to add multile items?
>
> Thanks!!!
> kes


Nov 19 '05 #5

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

Similar topics

3
by: Aymer | last post by:
i created a new button object. how do i attach an event on it? thanx for your help. Dim cc As ColorConverter = new ColorConverter() Dim b = new button() b.ID = "SelectedDate" b.BorderStyle...
8
by: timmy_dale12 | last post by:
I need help with this one. I have a function that pastes a row. In each row i am pasting a link which is to call a date picker javascript function. This is the code that pastes the link : link =...
1
by: Henke | last post by:
Hi I have a aspx-page with a panel-control. On this panel control I add user controls dynamicly with LoadControl and panel.Controls.Add(myControl). On some of the dynamicly added user controls I...
2
by: DaWoE | last post by:
Hi all, I'm fairly new to ASP.NET. What i want to do is creat a online registration form. On the first step is getting the users details and the number of people he wants to register. Based on...
0
by: Peer K | last post by:
Hello, This is driving me nuts! It's a bit hard to explain so please bare with me. I have an ASP.NET page that uses the calendar control. I use DayRender to set specific days selectable...
1
by: federicog | last post by:
I'm using this calendar: http://www.dynarch.com/projects/calendar/. I have three calendars on a page, and I need to "link" them together so that if I select a month in one calendar, the two...
4
by: yogarajan | last post by:
hi All my form contains lot of text box and 2 button one button is submit button and another one is calendar button when i am click this calendar button calendar is shown. i am creating required...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.