473,395 Members | 1,941 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,395 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 4504
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.