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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html 'onblur' code does not compile

Status
Not open for further replies.

JanVolley

Programmer
Sep 8, 2008
14
US
This has got to be a simple question. I am a newbie to asp.net and haven't used html much either. I'm trying to do what is described at: but I get the following error on my DatePicker.aspx:

"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,model=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 it does not compile.

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>
 
Have you tried compiling and running the code? If so, does it work? Ignore the fact the the XML transitional validation is failing.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- The Complete IT Community
 
the error says it all. your applying the blur to the body tag, not a specific control. the body cannot be blurred. forum216 is the best place to start.

using window.open you cannot create model windows like a desktop application. to get this type of effect you need to use div(s), js and css. jQuery is a good js library to use. there are plug-ins for this sort of effect.

FYI: js is never compiled, it's a scripting language. c#/vb are compiled languages.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Ignore my last comment about body onblur. My mind was somewhere else.

I'm confused as to what the actual problem is and when/where the problem occurs.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
The problem is that I am not able to build my application (via Visual Studio build) without getting the error that says that the 'onblur' attribute is not valid. Even if I still run the application, the 'onblur' isn't working there either.

The application is a data entry form that has a date field with a link next to it for a calendar. When the user clicks that link, the calendar window pops up (via Javascript window that includes the DatePicker.aspx). I want that popup window to stay on top.
 
js errors shouldn't prevent compiliation. chances are there is another error causing this.
as a test remove the onblur attribute and try compiling.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I bet if you close that page and do your build, it will compile with no error.

The problem is XHTML Transitional not recognizing the onblur event in the body as being valid. That doesn't mean what you are doing is an error.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- The Complete IT Community
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top