hi, there is nothing wrong with IE or firefox. It just happens that you have
wired an event to the body element which is not supported in firefox and it
gets simply ignored. while IE fires the event, though looking through the
events onblur does not seem to be supported on the body element, regardless
IE fires it and you get that awkward behaviour. Basically when you select
the dropdownlist, the dropdownlist gets the focus, causing the body elements
onblur to fire since it lost the focus. This is what is happening in IE.
What is the purpose of the onblur event you hooked up to the body element ?
Replace : <body onblur="this.window.focus();"> with <body> and it will work.
Regards,
Alessandro Zifiglio
http://www.AsyncUI.net
"rrd_angelofD" <
[email protected]> ha scritto nel messaggio
Hi!
Thank you for your time Alessandro.
Below is the html code of my date picker:
<body onblur="this.window.focus();" ms_positioning="FlowLayout">
<form id="Form1" method="post" runat="server">
<table align="center">
<tbody>
<tr>
<td><asp:dropdownlist id="drpCalMonth" Runat="Server"
AutoPostBack="True"></asp:dropdownlist><asp:dropdownlist
id="drpCalYear" Runat="Server"
AutoPostBack="True"></asp:dropdownlist></td>
</tr>
<tr>
<td align="center"><asp:calendar id="Calendar1" runat="server"
bordercolor="Black" showgridlines="True">
<TodayDayStyle ForeColor="#FFFFCC"
BackColor="#0066CC"></TodayDayStyle>
<SelectorStyle BackColor="#FFCC66"></SelectorStyle>
<NextPrevStyle Font-Size="9pt"
ForeColor="#FFFFCC"></NextPrevStyle>
<DayHeaderStyle Height="1px"
BackColor="#99FFFF"></DayHeaderStyle>
<SelectedDayStyle Font-Bold="True"
BackColor="#CCCCFF"></SelectedDayStyle>
<TitleStyle Font-Size="9pt" Font-Bold="True"
ForeColor="#FFFFCC" BackColor="#0066CC"></TitleStyle>
<OtherMonthDayStyle ForeColor="#CC99FF"></OtherMonthDayStyle>
</asp:calendar></td>
</tr>
</tbody>
</table>
<DIV><FONT face="MS UI Gothic"></FONT></DIV>
</form>
</body>
And the code behind is as follows:
private void Page_Load(object sender, System.EventArgs e)
{
if (!(Page.IsPostBack))
{
drpCalMonth.Items.Add("January");
drpCalMonth.Items.Add("February");
drpCalMonth.Items.Add("March");
drpCalMonth.Items.Add("April");
drpCalMonth.Items.Add("May");
drpCalMonth.Items.Add("June");
drpCalMonth.Items.Add("July");
drpCalMonth.Items.Add("August");
drpCalMonth.Items.Add("September");
drpCalMonth.Items.Add("October");
drpCalMonth.Items.Add("November");
drpCalMonth.Items.Add("December");
for(int i = 0; i < 12; i++)
{
drpCalMonth.Items
.Value = System.Convert.ToString(i + 1);
}
drpCalMonth.Items.FindByValue(DateTime.Now.Month.ToString()).Selected
= true;
for(int intYear = DateTime.Now.Year - 20; intYear <
DateTime.Now.Year + 20; intYear++)
{
drpCalYear.Items.Add(intYear.ToString());
}
drpCalYear.Items.FindByValue(DateTime.Now.Year.ToString()).Selected
= true;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Calendar1.DayRender+=new
DayRenderEventHandler(Calendar1_DayRender);
this.drpCalMonth.SelectedIndexChanged += new
System.EventHandler(this.drpCalMonth_SelectedIndexChanged);
this.drpCalYear.SelectedIndexChanged += new
System.EventHandler(this.drpCalYear_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
/// Replaces the standard post-back link for each calendar day
/// with the javascript to set the opener window's TextBox text.
/// Eliminates a needless round-trip to the server.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Calendar1_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
// Clear the link from this day
e.Cell.Controls.Clear();
// Add the custom link
System.Web.UI.HtmlControls.HtmlGenericControl Link = new
System.Web.UI.HtmlControls.HtmlGenericControl();
Link.TagName = "a";
Link.InnerText = e.Day.DayNumberText;
Link.Attributes.Add("href",
String.Format("JavaScript:window.opener.document.{0}.value = \'{1:d}\';
window.close();", Request.QueryString["field"], e.Day.Date));
// By default, this will highlight today's date.
if(e.Day.IsSelected)
{
Link.Attributes.Add("style",
this.Calendar1.SelectedDayStyle.ToString());
}
// Now add our custom link to the page
e.Cell.Controls.Add(Link);
}
private void drpCalMonth_SelectedIndexChanged(object sender,
EventArgs e)
{
Calendar1.TodaysDate =
System.Convert.ToDateTime(drpCalMonth.SelectedItem.Value + " 1, " +
drpCalYear.SelectedItem.Value);
}
private void drpCalYear_SelectedIndexChanged(object sender, EventArgs
e)
{
Calendar1.TodaysDate =
System.Convert.ToDateTime(drpCalMonth.SelectedItem.Value + " 1, " +
drpCalYear.SelectedItem.Value);
}
}
}
The weird thing is I tried removing all of the code and just left the
controls and it the bug is still there. It seems that the browser is
refreshing all the time because I can't even select the address bar.
The view source in firefox is clean but the view source in IE has a
bunch of garbage code which I don't know how it happened. The
following is a few sample of the view source in IE:
<td align="center"><table id="Calendar1" cellspacing="0"
cellpadding="2" rules="all" bordercolor="Black" border="1"
style="border-color:Black;border-width:1px;border-style:solid;border-collapse:collapse;">
<tr><td colspan="7" style="background-color:#0066CC;"><table
cellspacing="0" border="0"
style="color:#FFFFCC;font-size:9pt;font-weight:bold;width:100%;border-collapse:collapse;">
<tr><td style="color:#FFFFCC;font-size:9pt;width:15%;"><a
href="javascript:__doPostBack('Calendar1','V2343')"
style="color:#FFFFCC"><</a></td><td align="Center"
style="width:70%;">2006?7?</td><td align="Right"
style="color:#FFFFCC;font-size:9pt;width:15%;"><a
href="javascript:__doPostBack('Calendar1','V2404')"
style="color:#FFFFCC">></a></td></tr>
</table></td></tr><tr><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td><td align="Center"
style="background-color:#99FFFF;height:1px;">?</td></tr><tr><td
align="Center" style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/06/25';
window.close();">25</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/06/26';
window.close();">26</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/06/27';
window.close();">27</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/06/28';
window.close();">28</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/06/29';
window.close();">29</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/06/30';
window.close();">30</a></td><td align="Center" style="width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/07/01';
window.close();">1</a></td></tr><tr><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/02'; window.close();">2</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/03'; window.close();">3</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/04'; window.close();">4</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/05'; window.close();">5</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/06'; window.close();">6</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/07'; window.close();">7</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/08'; window.close();">8</a></td></tr><tr><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/09'; window.close();">9</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/10'; window.close();">10</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/11'; window.close();">11</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/12'; window.close();">12</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/13'; window.close();">13</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/14'; window.close();">14</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/15'; window.close();">15</a></td></tr><tr><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/16'; window.close();">16</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/17'; window.close();">17</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/18'; window.close();">18</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/19'; window.close();">19</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/20'; window.close();">20</a></td><td align="Center"
style="color:#FFFFCC;background-color:#0066CC;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/07/21';
window.close();">21</a></td><td align="Center" style="width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/07/22';
window.close();">22</a></td></tr><tr><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/23'; window.close();">23</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/24'; window.close();">24</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/25'; window.close();">25</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/26'; window.close();">26</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/27'; window.close();">27</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/28'; window.close();">28</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/29'; window.close();">29</a></td></tr><tr><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/30'; window.close();">30</a></td><td align="Center"
style="width:14%;"><a href="JavaScript:window.opener.document..value =
'2006/07/31'; window.close();">31</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/08/01';
window.close();">1</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/08/02';
window.close();">2</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/08/03';
window.close();">3</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/08/04';
window.close();">4</a></td><td align="Center"
style="color:#CC99FF;width:14%;"><a
href="JavaScript:window.opener.document..value = '2006/08/05';
window.close();">5</a></td></tr>
It looks like it's having a loop of some sort. Thank you very much for
your help.