ASP Calendar - cell "OnClick" event

Discussion in 'ASP .Net Web Controls' started by wwcoop, Sep 24, 2005.

  1. wwcoop

    wwcoop Guest

    The calendar control allows the user to select a date by clicking
    on the day number in the cell. I would like to extend
    this functionality so that the use can click anywhere in a calendar
    cell to trigger the selectionchanged event. I would like to assign
    an "OnClick" event to the calendar cell in the OnDayRender sub.
    How can I achieve the desired result?
    --
    Will Cooper
    MCSD .NET
     
    wwcoop, Sep 24, 2005
    #1
    1. Advertising

  2. wwcoop

    wwcoop Guest

    Thanks, you put me on the right path. Here is the solution:
    ******************************************
    Dim d as CalendarDay
    Dim c as TableCell
    Dim datOrigin as Date = "1-1-2000"
    Dim strDay as String

    d = e.Day
    c = e.Cell

    strDay = CStr(DateDiff("d", datOrigin, d.date))

    .....

    c.Attributes.Add("OnClick", "javascript:__doPostBack('ca','" & strDay &
    "')")
    ******************************************
    --
    Will Cooper
    Application Programmer


    "Peter Blum" wrote:

    > Hi Will,
    >
    > Here's a thought. The OnDayRender method is passed a TableCell control,
    > where you populate it with other controls. In this case, you want to add the
    > onclick event directly to the TableCell. The code for this is a post back,
    > which you use the Page.GetPostBackEventReference() method to generate the
    > right code. The trick is to generate the same elements in
    > GetPostBackEventReference() that the hyperlink on the day number does. That
    > takes some review of the HTML output to see what they do.
    >
    > cell.Attributes.Add("onclick", Page.GetPostBackEventReference(cell, "???",
    > "???"))
    >
    > Another approach is to replace the ASP.NET calendar with one built by a
    > third party that does not require post back. These calendars use javascript
    > and usually handle the onclick event on a day cell for you. Mine, the
    > CS_Calendar control inside of "Peter's Date Package"
    > (http://www.peterblum.com/datecontrols/home.aspx), can still optionally post
    > back. By using javascript, even if you elect to post back on each selection
    > change, you don't need to post back as the user changes months.
    >
    > You will find other third party calendars at the www.asp.net control
    > gallery, www.411asp.net, and www.123aspx.com.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "wwcoop" <> wrote in message
    > news:...
    > > The calendar control allows the user to select a date by clicking
    > > on the day number in the cell. I would like to extend
    > > this functionality so that the use can click anywhere in a calendar
    > > cell to trigger the selectionchanged event. I would like to assign
    > > an "OnClick" event to the calendar cell in the OnDayRender sub.
    > > How can I achieve the desired result?
    > > --
    > > Will Cooper
    > > MCSD .NET

    >
    >
    >
     
    wwcoop, Sep 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JerryG
    Replies:
    0
    Views:
    427
    JerryG
    Dec 20, 2005
  2. Garg
    Replies:
    1
    Views:
    232
    marss
    Mar 19, 2007
  3. bob
    Replies:
    3
    Views:
    192
  4. Barton
    Replies:
    2
    Views:
    196
    Lasse Reichstein Nielsen
    Dec 30, 2003
  5. Replies:
    18
    Views:
    144
    -Lost
    May 11, 2007
Loading...

Share This Page