.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Date not changing when selection changes in asp.net calendar

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net
Date either changes ramdomly or does not change at all. I find the ajax calendar extender a little hard to work with. Thanks.
Partial Class Default2
    Inherits System.Web.UI.Page

    Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim datebox As New TextBox
        Dim calendar1 As New Calendar
        datebox = CType(DetailsView1.FindControl("datebox"), TextBox)
        datebox.Text = calendar1.SelectedDate.ToShortDateString()
    End Sub
End Class

        <asp:DetailsView ID="DetailsView1" runat="server" Height="207px" Width="342px" DataSourceID="AccessDatasource"
            AutoGenerateEditButton="True" AutoGenerateDeleteButton="True" 
            AutoGenerateRows="False" AutoGenerateInsertButton="True" 
                <asp:TemplateField HeaderText="PODate" SortExpression="POdate">
                     <asp:TextBox ID="datebox" runat="server" Text='<

View Complete Post

More Related Resource Links

change calendar date backColor base on data from db


I want to  change calendar date backColor base on data from db,  I only have vistual 2003 !

on mean time I have

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 23px; POSITION: absolute; TOP: 271px"
		    runat="server" Font-Size="XX-Small" Font-Names="Verdana" AutoGenerateColumns="False" Visible="False">
           <asp:BoundColumn DataField="subject" HeaderText="Title"></asp:BoundColumn>
           <asp:BoundColumn DataField="posttimestart" HeaderText="Post date"></asp:BoundColumn>


Sub DayRender(ByVal source As Object, ByVal e As DayRenderEventArgs)
        Dim i As Integer
        For i = 0 To DataGrid1.Items.Count - 1
            If (DataGrid1.Items(i).Cells(1).Text = e.Day.Date) Then
                e.Cell.BackColor = Color.DarkOrange

            End If

    End Sub

when I click the day wich have data in db it change  color , but I want the page load it change color !

Thank you!

Calendar control and date


I have a calendar control , text box and a button . The calendar is invisible in the page load event. When I click on the button,It becomes visible. On selection of a date it becomes the value of the Text Box.
Having said that, my issue is that when this calendar becomes visible, it ruins the arrrangement of the controls on the  page. As I have other controls on the page they  comepletely get displaced. Is there a way to overlap this calendar over the other controls.
I had seen a control that was  some time ago and it was on the client side(probably using javascript or a third party control ) and It wud overlap the other controls and once a value was selected it became invisible.

Submtting Calendar items with variable date information via InfoPath 2007 form



I've seen several posts regarding submitting to a list using and InfoPath form which I am successfully able to do in limited form. (only passing a basic date value) My environment: MOSS 2007 Enterprise w/SP2, InfoPath 2007, SPD 2007.

I'm basically trying to recreate a calendar form with the same data elements (and some additional ones for a specific business requirement) as the standard calendar newform.aspx form. (start time, end time broken down by date, hour, minute and All day event)

I need the form users to be able to select the date and if it is not an All day event...be able to select the hours and minutes just like on the newform.aspx. (date picker control for date and drop downs for hour and minute selection)

On submit I then need to create the list item with the appropriate data passed via a workflow.

My Start Time has a validation rule to not allow dates prior to the current date (and it can't blank) The End Time has a validation rule to not allow dates prior to what is specified as the Start Time value. (Also can't be blank) When I attempt to include conditonal formatting to hide the hour and minute drop downs if 'All Day Event' is selected I get errors stating the fields can't be blank.

I also can't figure out how to pass the entire date/time values or the All Day Event to the list withou

Sort WSS 3.0 Calendar by Start Date

I have read a few posts about people not being able to sort by start date on the calendar.  Was wondering if anyone has this figured out to sort by start date correctly with re-occuring appointments?  I have a code snippet from another post but do not know how to format it correctly as I am a new sharepoint user.  If someone can help with that that is also appreciated.  Thanks.  Code Below:  I basically have no idea to find the info requested below <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script> //today's date var today = new Date(); //get the Date var myDate = today.getDate(); //get the Month var myMonth = today.getMonth()+1; //get the Year var myYear=today.getYear(); //put date into a mm/dd/yyyy format var myDate = myMonth + "/" + myDate + "/" + myYear; //If this is on a webparts page, get the WP div id.  If it's on a list page, you don't need the webzone div ID. //Get the table and table class (usually it's .listviewtable, but if you've customized a webpart, sometimes it's .ms-summarycustombody.  //I used Todd Bleeker's "Style Under Cursor WebPart" to find the CSS class. $(function(){ $('div#WebPartWPQ3 table.ms-listviewtable tr:not(:contains("' + myDate 

Outlook Calendar-like Free/Busy Time Selection Grid

Hello all, Does anyone know of an open source Outlook-like Free/Busy Grid? Or maybe have some starter ideas on how to go about building one. Thanks. - Randolph

Ajax Calendar Extender Question (about disable pass date)

HiI am wondering if it has anyway to disable the past day on the Ajax Calendar Control, previously, when we use CalendarExtender, we need to put a asp:Calendar and a textbox. we can use FindControl to find the calendar control and disable the past days.I am wondering is there anyway  could do the same stuff?Another question is how could I read the user selected date to the Date variable?Do i need to convert the date from the TargetControl ? E.g. Convert.ToDateTime(txt_DATE.text) ?Please let me know if you want me to explain more.Many thanksChi 

DataContractJsonSerializer changing my date

A user enters a date in a form, but when I pass the date through an AJAX json call, my date is getting changed by the DataContractJsonSerializer. Here's my AJAX call:function Save(){ //Convert date to milliseconds from from 1/1/1970 - necessary for passing a date through JSON var d = "09/01/2010 05:00"; myDate = new Date(d); myTicks = myDate.getTime(); var message = { MessageID: $("#MessageID").val(), MessageDate: '\/Date(' + myTicks + ')\/', }; $.ajax({ url: "<%= Url.Action("SaveMessage") %>", type: "POST", dataType: "json", data: $.toJSON(message), contentType: "application/json; charset=utf-8", success: function(result) { if (result && result.success) { // } } }); } Here's my serialization code:public override void OnActionExecuting(ActionExecutingContext filterContext){ if ((filterContext.HttpContext.Request.ContentType ?? string.Empty).Contains("application/json")) { var serializer = new DataContractJsonSerializer(RootType); filterContext.ActionParameters[Param] = serializer.ReadObject(filterContext.HttpContext.Request.InputStream); }} It's changing my dates to GMT. So if the user ente

Calendar Date Picker Restriction

Is there a way to restrict the user to selecting only the first day of a month from the Date Picker calendar? The database list the yearmonth column as datetime and the entries are 01/01/2010, 02/01/2010, 03/01/2010. . . to represent the month. So I need to be able to provide the calendar in the parameter panel but only let the user select the first day of a month. If I can't do this is there some way of providing an error message when/if they select another day of the month that would instruct them to select the first day of the month? Any help is greatly appreciated.

Problem displaying Date from Sql table on Calendar Control

Hi, I am displaying Event dates from SQL table on Calendar Control in ASP.NET. Also, I have GridView Control which shows event details when certain date is clicked on calendar control. But I have a problem as not all dates are displaying properly. Strangly enough only dates which have same month and day date are displayed. For example: It shows ok dates such as 08/08/2010, 09/09/2010, 10/10/2010 etc. If I click on the date which in SQL table exists as 11/25/2010 or 12/15/2010 etc (no matching month/day numbers) it shows error message saying: "System.Data.SqlClient.SqlException: Conversion failed when converting date and/or time from character string."  Follwoing is my code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.Sql; using System.Runtime.Remoting.Messaging; using System.Configuration; using System.Data.SqlClient; using System.Data; using System.Drawing; public partial class Test_Calendar : System.Web.UI.Page { SqlConnection mycn; SqlDataAdapter myda; DataSet ds = new DataSet(); DataSet dsSelDate; String strConn; private void Page_Load(object sender, System.EventArgs e) { strConn = "Data Source=mydatasource;Initial Catalog=DBname;Persist Security I

change the date rang in calendar depend on the data from db

if the calendar day is match with the date in db I can change the claendar 's background color  with the following code , How if I want  my calendar change color by the range of the data in my db ,  said I want the calendar change color from the starDay to endday of the event , the date rang is random what can I do ??  For Each dr In tmpds.Tables(0).Rows                    If Not dr("startDay") Is DBNull.Value Then                        Dim dtEvent As DateTime = dr("startDay").ToString

How to display the date only till current date in ajax calendar extender .

Hi,1) How can i display the date only till current date in ajax calendar extender ?2)How to validate the date in one TextBox with the Date in another TextBox ?    Please Help me ...

How to stop Page loading after selecting a date in Calendar in aspx page



can anybody plz tell me how to stop re-loading of page after selecting a date from a  calendar control in a aspx page.

I want to show the selected date in a Textbox control but i don't want to re-load the page.




How to change the date format using AJAX calendar control tookit


I want to desplay date like (21-Sep-2010)

Validate ASP.net calendar date selected with Javascript?


Is there any way I can use javascript to make sure the user has selected a date from my asp.net calendar? I have the calendar under an update panel:

                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="Maroon"
                                    BorderWidth="1px" CssClass="calendar" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black"
                                    Height="200px" Width="305px" DayNameFormat="Shortest" ShowGridLines="False">
                                    <SelectedDayStyle BackColor="maroon" BorderColor="Black" BorderWidth="1px" Font-Bold="true" Font-Size="11pt" />
                                    <SelectorStyle BackColor="#FFCC66" />
                                    <TodayDayStyle Font-Bold="true" Font-Size="16pt"/>
                                    <OtherMonthDayStyle ForeColor="#CC9966" />

Calendar date format


Can anyone tellme how to change the calendar date format ? It is currently using the american date format and I want to change it to UK.


Does it use the servers regional options? If so these look to be correct.


Any advise on this would be greatly appreciated.


Many Thanks in advanced.


Wendy Ewens

Changing Date format in Filter toolbar


i have added a toolbar to a Data View Web Part and enabled the Filter option. When i click on the filter, the Due Date field displays choices as Saturday, September 11, 2010. Within the DWVP I have the format set to mm/dd/yyyy, the differening formats seem to prevent the filter from working. How I can change the format in the filter dropdown ?

Thanks in advance

Dean MCTS-SQL 2005 Business Intelligence

Default date selection in SSRS with SSAS cube as a source




I am fairly new to SSAS and I am hoping that someone can help me with an issue I am experiencing.  I am create a SSRS report that goes against a SSAS cube.  My cube has a Date dimension with a Fiscal Year - Fiscal Quarter - Fiscal Month hierarchy.  In my report I have created filters for a From Date and a To Date, which are populated with the hierarchy of the Date dimension.


I need to default the filters as follows:


To Date = current quarter (that is the last quarter with fact data)

From Date = the To Date quarter from the previous year (e.g. if To Date quarter = Q1 2008, then From Date quarter needs to be Q1 2007)


I found some SSAS code that allows me to get the index of the last quarter with data, but I am stuck at this point.  I am not sure how I can translate this into a default selection for the To Date SSRS report parameter.  I also realize that there may be a better approach.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend