Calendar Link in Datagrid

Discussion in 'ASP .Net Datagrid Control' started by John Walker, Jul 12, 2005.

  1. John Walker

    John Walker Guest

    Hi,
    In my datagrid I have a textbox with a hyperlink next to it. When the user
    clicks on the hyperlink it will pop open another window with a calendar
    control, and when the user clicks a date, it will put that date in the
    aforementioned textbox and close the calendar window. Here's the javascript
    which is added to the hyperlink during ItemDataBound:

    '-----> BEGIN (txtScheduledDelivery is the textbox control which gets
    populated with the date)

    hlScheduledDeliveryCal = CType(e.Item.FindControl("hlScheduledDeliveryCal"),
    HyperLink)

    hlScheduledDeliveryCal.NavigateUrl =
    "javascript:calendar_window=window.open('../controls/calendar.aspx?formname="
    & RTrim(txtScheduledDelivery.UniqueID) &
    "','calendar_window','width=154,height=184,top=220,left=500');calendar_window.focus()"

    '-----> END

    The issue is, our customer wants the popup calendar window to always pop up
    right next to the hyperlink, so that the lazy users won't have to move the
    mouse too far. Has anyone else needed to control the nearly exact position
    of a popup window? Can it be easily done?

    Thanks,
    John
     
    John Walker, Jul 12, 2005
    #1
    1. Advertisements

  2. Hi John

    Try this code sample and let us know. I hope it will work

    hlScheduledDeliveryCal = CType(e.Item.FindControl("hlScheduledDeliveryCal"),
    HyperLink)

    hlScheduledDeliveryCal.Attributes.Add("onclick", "Go(this.offsetTop,
    this.offsetLeft + this.offsetWidth, '" &
    RTrim(txtScheduledDelivery.UniqueID) & "');")

    Add a javascript function to the client side.

    function Go(top, left, UniqueID)
    {
    var
    calendar_window=window.open('../controls/calendar.aspx?formname=UniqueID',
    'calendar_window','width=154,height=184,top=' + top + ',left=' + left);
    calendar_window.focus();
    }

    Regards
    Fiaz Ali Saleemi
     
    Fiaz Ali Saleemi, Jul 14, 2005
    #2
    1. Advertisements

  3. Hi John

    Try this code sample and let us know. I hope it will work

    hlScheduledDeliveryCal = CType(e.Item.FindControl("hlScheduledDeliveryCal"),
    HyperLink)

    hlScheduledDeliveryCal.Attributes.Add("onclick", "Go(this.offsetTop,
    this.offsetLeft + this.offsetWidth, '" &
    RTrim(txtScheduledDelivery.UniqueID) & "');")

    Add a javascript function to the client side.

    function Go(top, left, UniqueID)
    {
    var calendar_window = window.open('../controls/calendar.aspx?formname=' +
    UniqueID,
    'calendar_window', 'width=154,height=184,top=' + top + ',left=' + left);
    calendar_window.focus();
    }

    Regards
    Fiaz Ali Saleemi
     
    Fiaz Ali Saleemi, Jul 14, 2005
    #3
  4. John Walker

    John Walker Guest

    Fiaz,

    Thanks! I'll give it a try and let you know.

    John

    "Fiaz Ali Saleemi" wrote:

    > Hi John
    >
    > Try this code sample and let us know. I hope it will work
    >
    > hlScheduledDeliveryCal = CType(e.Item.FindControl("hlScheduledDeliveryCal"),
    > HyperLink)
    >
    > hlScheduledDeliveryCal.Attributes.Add("onclick", "Go(this.offsetTop,
    > this.offsetLeft + this.offsetWidth, '" &
    > RTrim(txtScheduledDelivery.UniqueID) & "');")
    >
    > Add a javascript function to the client side.
    >
    > function Go(top, left, UniqueID)
    > {
    > var calendar_window = window.open('../controls/calendar.aspx?formname=' +
    > UniqueID,
    > 'calendar_window', 'width=154,height=184,top=' + top + ',left=' + left);
    > calendar_window.focus();
    > }
    >
    > Regards
    > Fiaz Ali Saleemi
    >
    >
    >
    >
     
    John Walker, Jul 14, 2005
    #4
  5. John Walker

    John Walker Guest

    Fiaz,

    I applied your code but the offsets weren't what I had expected. The
    hyperlink on every row in the datagrid showed the the same values. The
    values were:
    offsetTop - 1
    offsetLeft - 77
    offsetWidth - 31

    The calendar would appear in the upper left hand area of the screen, even
    though I was clicking on a hyperlink in the lower right hand side of the
    browser. I applied your code exactly as you posted it. Might you have any
    idea what I'm doing wrong?

    Thanks again,
    John

    "Fiaz Ali Saleemi" wrote:

    > Hi John
    >
    > Try this code sample and let us know. I hope it will work
    >
    > hlScheduledDeliveryCal = CType(e.Item.FindControl("hlScheduledDeliveryCal"),
    > HyperLink)
    >
    > hlScheduledDeliveryCal.Attributes.Add("onclick", "Go(this.offsetTop,
    > this.offsetLeft + this.offsetWidth, '" &
    > RTrim(txtScheduledDelivery.UniqueID) & "');")
    >
    > Add a javascript function to the client side.
    >
    > function Go(top, left, UniqueID)
    > {
    > var calendar_window = window.open('../controls/calendar.aspx?formname=' +
    > UniqueID,
    > 'calendar_window', 'width=154,height=184,top=' + top + ',left=' + left);
    > calendar_window.focus();
    > }
    >
    > Regards
    > Fiaz Ali Saleemi
    >
    >
    >
    >
     
    John Walker, Jul 14, 2005
    #5
    1. Advertisements

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. Shevek
    Replies:
    3
    Views:
    6,472
    Shevek
    Jun 23, 2004
  2. Peer K

    Direct link into calendar control

    Peer K, Dec 1, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    Peer K
    Dec 1, 2004
  3. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    dynamicly add link button to calendar cel

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, May 11, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    6,566
    Karl Seguin
    May 13, 2005
  4. Replies:
    0
    Views:
    449
  5. Graham Thomson
    Replies:
    3
    Views:
    640
    Eki Y. Baskoro
    Dec 18, 2003
  6. Shevek
    Replies:
    0
    Views:
    567
    Shevek
    Jun 23, 2004
  7. Parthiv Joshi
    Replies:
    1
    Views:
    1,103
    Samuel L Matzen
    Jul 6, 2004
  8. hivan

    Calendar and link

    hivan, Aug 23, 2003, in forum: Javascript
    Replies:
    4
    Views:
    238
    hivan
    Aug 24, 2003
Loading...