CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 ASP calendar script results appears at top of page

Print topic Send  topic

Author Message
CodeCharge
Posted: 07/05/2003, 11:28 AM

How do I get the following script to appear on a page where I want it to?
It always appears at the top of the page. I have tried to add the code to a
label in a form at all the "before show", "after show", etc... events but
nothing seems to work. I have turned on and off buffering. I want to use
it in the portal example but am unable to have the results (the calendar)
appear where I need them to. I have been at this for days now and am at my
wits end. HELP!!!!

<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0>
<!-- This is the top row for the calendar -->
<TR>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>S</B></TD>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>M</B></TD>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>T</B></TD>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>W</B></TD>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>T</B></TD>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>F</B></TD>
<TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>S</B></TD>
</TR>
<%
' Get the current month and year
iThisMonth = Month(Date)
iThisYear = Year(Date)

' Determine what day the first of the month falls
iFirstWeekDay = WeekDay(DateSerial(iThisYear, _
iThisMonth, 1))

' Determine the number of days in the month
iNoDays = Day(DateSerial(iThisYear, _
iThisMonth + 1, 0))

' Initialize the day to the first cell of the
' month. If the day does not fall in the month,
' it will have a negative value until
' the month begins
iDay= 2 - iFirstWeekDay

' Create a calendar of 6 rows; 6 is the maximum
' weeks in any given month
For iRows = 1 To 6
Response.Write "<TR>" & vbCrLf
' Inner loop prints the days in a week. In
' other words, prints the date columns
For iLoop = 1 To 7
' Check if the day falls within the month.
' If not, print a blank cell.
If iDay < 1 Or iDay > iNoDays Then
Response.Write "<TD> </TD>" & vbCrLf
Else
' The day falls within the month print it.
Response.Write "<TD ALIGN='RIGHT'>" & _
iDay & "</TD>" & vbCrLf
End If

' Increment the day count
iDay = iDay + 1
Next

Response.Write "</TR>" & vbCrLf
Next
%>
</TABLE>


DonB
Posted: 07/05/2003, 3:09 PM

The reason is that the Response.Write executes immediately, but the page is
not actually output until later on (after all "BeforeShow" events are
completed) in the "Show Page" section of the page's asp code. So, your
calendar appears as the first part of the html stream output to the browser.

The way I've overcome this is to pump the html into a variable and output it
to a Label control. See http://www.gotodon.com, where I have done exactly
what you desired, with my own calendar. This puts the html exactly where
you want it.

DonB



"CodeCharge" <heywood90@hotmail.com> wrote in message
news:be75d0$c58$1@news.codecharge.com...
> How do I get the following script to appear on a page where I want it to?
> It always appears at the top of the page. I have tried to add the code to
a
> label in a form at all the "before show", "after show", etc... events but
> nothing seems to work. I have turned on and off buffering. I want to use
> it in the portal example but am unable to have the results (the calendar)
> appear where I need them to. I have been at this for days now and am at
my
> wits end. HELP!!!!
>
> <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0>
> <!-- This is the top row for the calendar -->
> <TR>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>S</B></TD>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>M</B></TD>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>T</B></TD>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>W</B></TD>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>T</B></TD>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>F</B></TD>
> <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>S</B></TD>
> </TR>
> <%
> ' Get the current month and year
> iThisMonth = Month(Date)
> iThisYear = Year(Date)
>
> ' Determine what day the first of the month falls
> iFirstWeekDay = WeekDay(DateSerial(iThisYear, _
> iThisMonth, 1))
>
> ' Determine the number of days in the month
> iNoDays = Day(DateSerial(iThisYear, _
> iThisMonth + 1, 0))
>
> ' Initialize the day to the first cell of the
> ' month. If the day does not fall in the month,
> ' it will have a negative value until
> ' the month begins
> iDay= 2 - iFirstWeekDay
>
> ' Create a calendar of 6 rows; 6 is the maximum
> ' weeks in any given month
> For iRows = 1 To 6
> Response.Write "<TR>" & vbCrLf
> ' Inner loop prints the days in a week. In
> ' other words, prints the date columns
> For iLoop = 1 To 7
> ' Check if the day falls within the month.
> ' If not, print a blank cell.
> If iDay < 1 Or iDay > iNoDays Then
> Response.Write "<TD> </TD>" & vbCrLf
> Else
> ' The day falls within the month print it.
> Response.Write "<TD ALIGN='RIGHT'>" & _
> iDay & "</TD>" & vbCrLf
> End If
>
> ' Increment the day count
> iDay = iDay + 1
> Next
>
> Response.Write "</TR>" & vbCrLf
> Next
> %>
> </TABLE>
>
>
>

CodeCharge
Posted: 07/05/2003, 11:24 PM

Thanks Don!
How would I go about doing this?
I have additional code for an events calendar (each day is a hyperlink with
events pulled from a db), I can get it to work outside codecharge but don't
know how to integrate it within the CCS environment.

Heywood

"DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
news:be7iar$r1j$1@news.codecharge.com...
> The reason is that the Response.Write executes immediately, but the page
is
> not actually output until later on (after all "BeforeShow" events are
> completed) in the "Show Page" section of the page's asp code. So, your
> calendar appears as the first part of the html stream output to the
browser.
>
> The way I've overcome this is to pump the html into a variable and output
it
> to a Label control. See http://www.gotodon.com, where I have done exactly
> what you desired, with my own calendar. This puts the html exactly where
> you want it.
>
> DonB
>
>
>
> "CodeCharge" <heywood90@hotmail.com> wrote in message
>news:be75d0$c58$1@news.codecharge.com...
> > How do I get the following script to appear on a page where I want it
to?
> > It always appears at the top of the page. I have tried to add the code
to
> a
> > label in a form at all the "before show", "after show", etc... events
but
> > nothing seems to work. I have turned on and off buffering. I want to
use
> > it in the portal example but am unable to have the results (the
calendar)
> > appear where I need them to. I have been at this for days now and am at
> my
> > wits end. HELP!!!!
> >
> > <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0>
> > <!-- This is the top row for the calendar -->
> > <TR>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>S</B></TD>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>M</B></TD>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>T</B></TD>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>W</B></TD>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>T</B></TD>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>F</B></TD>
> > <TD ALIGN="RIGHT" VALIGN="BOTTOM"><B>S</B></TD>
> > </TR>
> > <%
> > ' Get the current month and year
> > iThisMonth = Month(Date)
> > iThisYear = Year(Date)
> >
> > ' Determine what day the first of the month falls
> > iFirstWeekDay = WeekDay(DateSerial(iThisYear, _
> > iThisMonth, 1))
> >
> > ' Determine the number of days in the month
> > iNoDays = Day(DateSerial(iThisYear, _
> > iThisMonth + 1, 0))
> >
> > ' Initialize the day to the first cell of the
> > ' month. If the day does not fall in the month,
> > ' it will have a negative value until
> > ' the month begins
> > iDay= 2 - iFirstWeekDay
> >
> > ' Create a calendar of 6 rows; 6 is the maximum
> > ' weeks in any given month
> > For iRows = 1 To 6
> > Response.Write "<TR>" & vbCrLf
> > ' Inner loop prints the days in a week. In
> > ' other words, prints the date columns
> > For iLoop = 1 To 7
> > ' Check if the day falls within the month.
> > ' If not, print a blank cell.
> > If iDay < 1 Or iDay > iNoDays Then
> > Response.Write "<TD> </TD>" & vbCrLf
> > Else
> > ' The day falls within the month print it.
> > Response.Write "<TD ALIGN='RIGHT'>" & _
> > iDay & "</TD>" & vbCrLf
> > End If
> >
> > ' Increment the day count
> > iDay = iDay + 1
> > Next
> >
> > Response.Write "</TR>" & vbCrLf
> > Next
> > %>
> > </TABLE>
> >
> >
> >
>
>

DonB
Posted: 07/06/2003, 9:23 AM

Take the code that builds your calendar and put it into a function. Instead
of the Response.Writes, stuff the html into a variable and had the function
return that as a string. You can call the function wherever it makes sense,
such as the page's BeforeShow event, and save it into a variable that is
declared "global" to the page (so it is available to the event routines).
Then the Label's BeforeShow event (which occurs after the PageShow) will see
this variable already defined and you can merely assign the label like this:
Label1.Value = <your global variable>


DonB

"CodeCharge" <heywood90@hotmail.com> wrote in message
news:be8fbm$srs$1@news.codecharge.com...
> Thanks Don!
> How would I go about doing this?
> I have additional code for an events calendar (each day is a hyperlink
with
> events pulled from a db), I can get it to work outside codecharge but
don't
> know how to integrate it within the CCS environment.
>
> Heywood
>

CodeCharge
Posted: 07/07/2003, 12:37 PM

Thanks Don,
Below is the revised code for others if they are interested. I added this
to the commom.asp file, created a new page, put a label on it and called the
function with "label.value=Calendar()". The calendar appears whereever I
need it to.


>----
Function Calendar()
Dim content,iThisMonth, iThisYear, iFirstWeekDay, iNoDays, iDay, iLoop,
iRows

content= "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0><TR><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>S</B></TD><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>M</B></TD><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>T</B></TD><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>W</B></TD><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>T</B></TD><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>F</B></TD><TD ALIGN='RIGHT'
VALIGN='BOTTOM'><B>S</B></TD></TR>"
' Get the current month and year
iThisMonth = Month(Date)
iThisYear = Year(Date)

' Determine what day the first of the month falls
iFirstWeekDay = WeekDay(DateSerial(iThisYear, iThisMonth, 1))

' Determine the number of days in the month
iNoDays = Day(DateSerial(iThisYear, iThisMonth + 1, 0))
'
' Initialize the day to the first cell of the
' month. If the day does not fall in the month,
' it will have a negative value until
' the month begins
iDay= 2 - iFirstWeekDay

' Create a calendar of 6 rows; 6 is the maximum
' weeks in any given month
For iRows = 1 To 6
' content= content & "<TR>" & vbCrLf
' Inner loop prints the days in a week. In
' other words, prints the date columns
For iLoop = 1 To 7
' Check if the day falls within the month.
' If not, print a blank cell.
If iDay < 1 Or iDay > iNoDays Then
content= content & "<TD> </TD>" & vbCrLf
Else
' The day falls within the month print it.
content= content & "<TD ALIGN='RIGHT'>" & _
iDay & "</TD>" & vbCrLf
End If

' Increment the day count
iDay = iDay + 1
Next

content= content & "</TR>" & vbCrLf
Next

content=content & "</TABLE>"
calendar=content
End Function

"DonB" <7432D63DBB01D03A196B1EDD80E8@comcast.net> wrote in message
news:be9ie1$9d6$1@news.codecharge.com...
> Take the code that builds your calendar and put it into a function.
Instead
> of the Response.Writes, stuff the html into a variable and had the
function
> return that as a string. You can call the function wherever it makes
sense,
> such as the page's BeforeShow event, and save it into a variable that is
> declared "global" to the page (so it is available to the event routines).
> Then the Label's BeforeShow event (which occurs after the PageShow) will
see
> this variable already defined and you can merely assign the label like
this:
> Label1.Value = <your global variable>
>
>
> DonB
>
> "CodeCharge" <heywood90@hotmail.com> wrote in message
>news:be8fbm$srs$1@news.codecharge.com...
> > Thanks Don!
> > How would I go about doing this?
> > I have additional code for an events calendar (each day is a hyperlink
> with
> > events pulled from a db), I can get it to work outside codecharge but
> don't
> > know how to integrate it within the CCS environment.
> >
> > Heywood
> >
>
>


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.