ASP.NET Calendar Question...

I'm still pretty new to ASP.NET & I've come across a seemingly trivial issue that I'm having trouble with. Basically, I have a simple Calendar on my .aspx page and what I'd like to have is a simple function that returns the currently selected Date of the calendar. I guess I'm just a bit unfamiliar with declaring Evant Handlers in order to do this. I can write a function displaying everything properly, but writing & declaring one that successfully returns the selected date to my Page_Load function is escaping me.

My inteded goal is to have a displayed table with 2 header names that are the selected date & month from the caledar. Then I'll pull some relevant data from my database.

If one has any suggestions, I would be grateful. :) Thanks again.Well sure am a newb. By simply stating: CalendarName.SelectedDate I achieve what I wanted. I keep making things way more difficult then they really are. Sheesh. :splat:Sorry, had an errant onLoad="Page_Load" in there. *sigh*Can anyone explain why...when I define a function to fire when a WebForm Calendar's Visible Month is changed (i.e. - someone clicks the little arrow next to the month name and changes the displayed month) as follows:


<asp:Calendar id="AgntTotals" style="DISPLAY: inline; Z-INDEX: 101; MARGIN: 0px 0px 10px 10px" runat="server" Width="376px" Height="56px" BorderColor="Black" ShowGridLines="True" OnSelectionChanged="AgntTotals_SelectionChanged" OnVisibleMonthChanged="AgntTotals_VisibleMonthChanged">

I get the error that:

" BC30390: 'QueUpdtr.WebForm1.Private Sub AgntTotals_VisibleMonthChanged(sender As Object, e As System.Web.UI.WebControls.MonthChangedEventArgs)' is not accessible in this context because it is 'Private'."

I'm not sure why this would be 'Private'? I've defined the OnSelectionChanged to fire when someone selects a different day of the calendar, and this works fine, but the OnVisibleMonth change function doesn't work at all...

Am I missing something simple?

EDIT: Yes I am missing something simple indeed...seems I always am. :( My function definition was wrong...

Change This:

Sub AgntTotals_VisibleMonthChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

To This:

Sub AgntTotals_VisibleMonthChanged(ByVal sender As System.Object, ByVal e As MonthChangedEventArgs)was about to ask you about the event delegate the definitions must match...


Easy way to handle if you're using VS.net then, on the property pane, there is a little lighting bolt. That is the event display... double the event you want. It will write the needed code for Not only the delegate but the wiring to the page IE

this.Load += Page_Load;


which is a method that matches the delegate signature, and the words "this.Load" is C++ syntax, it refers to the current object with "this" and Load is the event declartion.

You might just want to read up delegates as it will allow you to better understand how things work. Also help you build apps better.Will do, thanks for the help. I tried using the Events display in VS.NET, but I guess I didn't follow through. Obviously I'm not doing the best job of teaching myself how to use ASP.NET...but I'm slowly learning. Thanks again Afterburn.

EDIT: Mind if I ask one more question regarding your suggestions Afterburn...

I did as you said and went into the Events pane in VS.NET and double clicked my event function and the apsx.cs file opens up. And the definition for my specific function is...


private void AgntTotals_VisibleMonthChanged(object sender, System.Web.UI.WebControls.MonthChangedEventArgs e)
{
this.Response.Write("MONTH CHANGED<br>");
}


Is this what you meant? It's just a test function to display a messeage when the month is changed.

However, if I define this in my .aspx file using Visual Basic and just a s Sub statement, it works just fine. What am I missing?Originally posted by RCurrie
Will do, thanks for the help. I tried using the Events display in VS.NET, but I guess I didn't follow through. Obviously I'm not doing the best job of teaching myself how to use ASP.NET...but I'm slowly learning. Thanks again Afterburn.

EDIT: Mind if I ask one more question regarding your suggestions Afterburn...

I did as you said and went into the Events pane in VS.NET and double clicked my event function and the apsx.cs file opens up. And the definition for my specific function is...


private void AgntTotals_VisibleMonthChanged(object sender, System.Web.UI.WebControls.MonthChangedEventArgs e)
{
this.Response.Write("MONTH CHANGED<br>");
}


Is this what you meant? It's just a test function to display a messeage when the month is changed.

However, if I define this in my .aspx file using Visual Basic and just a s Sub statement, it works just fine. What am I missing?

A "Sub" is VB.net syntax for a function that returns no value.


in C# its "void" keyword.

It the same thing. But if you already have a event defined it will just jump to that event without creating it.
 
Back
Top