Calendar Link in Datagrid

J

John Walker

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
 
F

Fiaz Ali Saleemi

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
 
F

Fiaz Ali Saleemi

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
 
J

John Walker

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top