Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modal window in web app?

Status
Not open for further replies.

JanVolley

Programmer
Sep 8, 2008
14
US
I am a newbie to javascript and web development. I have an asp.net web form and am trying to popup a DataPicker-like modal window so that the user can select a date from a calendar. I think this is pretty typical stuff. I'm trying to do what is described at: but it doesn't work and I get the following error on my DatePicker.aspx (asp.net web form):

"Validation (XHTML 1.0 Transitional): Attribute 'onblur' is not a valid attribute of element 'body'."


I've created a calendar webform that will popup from a data entry form when a user clicks on a link to input a date value. I use Javascript to pop this window up using the code below in my data entry form:

<script language="javascript" type="text/javascript">
function calendarPicker(strField)
{
window.open('DatePicker.aspx?field=' + strField, 'calendarPopup', 'width=250,height=190,resizable=yes,left=560,top=720,modal=yes');
}
</script>



I want the calendar popup window to be modal so that it is always on top, so I want to use onblur="this.window.focus();"> within the body tag, but I get a build error.

Can someone please tell me why I can't use this? I see many examples on the internet for using onblur in the body tag. Below is my DatePicker.aspx code:



<%@ Page Language="C#" AutoEventWireup="false" CodeFile="DatePicker.aspx.cs" Inherits="DatePicker" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns=" <head id="Head1" runat="server">
<title>Select a Date</title>
</head>
<body onblur="this.window.focus();">
<form id="DatePickerForm" method="post" runat="server" title="Select a Date">
<div align="center">
<asp:calendar id="Calendar1" runat="server" showgridlines="True" bordercolor="Black" OnDayRender="Calendar1_DayRender">
<todaydaystyle forecolor="White" backcolor="#FFCC66"/>
<selectorstyle backcolor="#FFCC66"/>
<nextprevstyle font-size="9pt" forecolor="#FFFFCC"/>
<dayheaderstyle height="1px" backcolor="#FFCC66"/>
<titlestyle font-size="9pt" font-bold="True" forecolor="#FFFFCC" backcolor="#990000"/>
<othermonthdaystyle forecolor="#CC9966"/>
</asp:calendar>
</div>
</form>
</body>
</html>
 
Can someone please tell me why I can't use this?

Personal answer: because it's bloody annoying.

Professional answer: because not all browsers support this, and so you should try and aim for consistent functionality, I'd say.

I see many examples on the internet for using onblur in the body tag.

And do they validate?

The reason you're using this, I understand from the page you linked to is:

The BODY tag contains a simple script that runs in the onBlur event (clientside) to turn the popup into a modal dialog box.

As already mentioned, not all browsers support this, and I don't think it's something that should be encouraged. Perhaps think about using a DHTML popup instead that sits over your content.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top