Tim
[Denver, CO]
"Tim Goldstein" <ti...@ktmarketing.com> wrote in message
news:OijTAW$vBHA.2500@tkmsftngp03...
Any other ideas?
Tim
[Denver, CO]
"Gabor" <prof...@elender.hu> wrote in message
news:OmkxRgFwBHA.2020@tkmsftngp02...
The answer is that you can override the __doPostBack function to add your
own client code for the calendar control. I'm including a sample below.
However, you are very limited in what you can do.
You might find that using a purely client-side calendar control is a better
solution for you. There are several client-side calendars (including source
code) at http://javascript.internet.com/calendars/ (thanks to Calvin Guo
for this link).
---
The calendar server control was designed to be processed on the server. The
calendar is rendered on the browser as a table. The individual <td> tags do
NOT have their own unique ID's. Therefore, trying to process user activity
on the client is difficult.
For example, to change which day is selected requires changing the styles
of the previously selected <td> tag and that of the newly selected tag.
Since these tags do not have ID's, it is difficult to do this in client
code.
Something you can do is make the entire calendar control dissappear. First,
override the __doPostBack function (this is shown below). Then place this
code in your new post back function (here I call it NewPostBack):
document.getElementById("Calendar1").outerHTML="";
---
Here is a sample which overrides submission of the calendar control.
Instead of submitting, it erases the calendar control. It also allows other
controls to submit.
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Cal1.aspx.vb"
Inherits="nClientButton.Cal1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Cal1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script id="clientEventHandlersJS" language="javascript">
<!--
var oldPostBack
function newPostBack(eventTarget, eventArgument) {
if (eventTarget == "Calendar1") {
//If the call to __doPostBack was from Calendar1, then
//erase Calendar1 and do not call the original __doPostBack.
document.getElementById("Calendar1").outerHTML="";
}
else {
//If the call to __doPostBack was NOT from Calendar1, then
//call the original __doPostBack.
oldPostBack(eventTarget, eventArgument);
}
}
function window_onload() {
oldPostBack = __doPostBack;
__doPostBack = newPostBack;
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" language="javascript" onload="return
window_onload()">
<form id="Form1" method="post" runat="server">
<asp:Calendar id="Calendar1" style="Z-INDEX: 101; LEFT: 169px; POSITION:
absolute; TOP: 21px" runat="server"></asp:Calendar>
</form>
</body>
</HTML>
---
Thank you, Mike Moore
Microsoft ASP.NET Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.