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

Top 5 Contributors of the Month
Post New Web Links

datepicker initial value

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :ASP.Net

how do I assign an initial value to an <input type='text"> element that has a jquery datepicker hooked onto it?

Setting the value either thru the element attribute or the jquery val() method does not work.


    <span>Date from</span>
<input id='textReportsFromDate' type='text' style="width:5em;"/>

<script type="text/javascript">
  $(document).ready(function ()
    var dp1 = $("#textReportsFromDate").datepicker();

    // optional. shows how to set datepicker options.
      dateFormat: 'yy-m-d',
      numberOfMonths: [1, 2],
      showWeek: 'true'



View Complete Post

More Related Resource Links

UI Datepicker and web user controls



I have developed an application using the Master-Detail pattern described in this Matt Berseth article.

The only difference between Matt's article and me is that I am using a FormView object in place of a DetailsView.

Everything works fine except that the formview object, in my case it's inside a user control and I can't figure out how to use the jquery datepicker UI plugin.

I have tried to put the script block for the datepicker either in the aspx page as well as inside the user control but in both cases the calendar does not come up when the related textbox get the focus.

Any suggestion on how to work with the datepicker inside an ascx?

thanks in advance!

jquery datepicker not popping up in Gridview Edit Template textbox


I have a gridview that I can't for the life of me get the datepicker calender to pop up for.  I've been using the datepicker for months very successfully for a variety of textboxes on the page and inside of formviews but this is the first time I've tried using with gridview.  I didn't expect any issues however can't seem to find anything to work.  I have searched the forums for 2 days and attempted any suggestions found within the solutions to no avail.  I've tried using the CSS to link the datepicker but everything stopped working when I changed the code and my page which uses a css style already got all distorted looking.  Please help!

Here is my gridview (only included a part b/c it is large and am only having problem with the datepicker for the date completed text box)

<asp:GridView ID="GridViewCompleted" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
        BorderWidth="3px" CellPadding="4" DataKeyNames="job_id" DataSourceID="SourceJobProjectCompleted"
        ForeColor="Black" CellSpacing="2">

Size of jQuery datepicker popup


I have several mvc applications all using the jquery datepicker. One of them the popup appears double size (height and width), obvously it's something I've inadvertantly changed, probably in the css, but I can't figure out what it is. I have tried/applied a few themes and css/site master from the mvc code templates on codeplex, but I just can't figure out what did this one.

Any ideas ?

(MVC & jQuery) Can't Add Datepicker to List of form elements



I'm still relatively new to jQuery (mostly finding things I need online and making simple changes). I have the following piece of code in my MVC app to render a partial view

<% int i = 0;
   foreach (var item in Model) { %>

        <td valign="top" style="border: none;">
            <%= Html.TextBox("MeetingList[" + i + "].Start", String.Format("{0:MM/dd/yyyy HH:mm}", item.Start), new { @style = "width: 120px;", @class="start" })%>
        <td valign="top" style="border: none;">
            <%= Html.TextBox("MeetingList[" + i + "].End", String.Format("{0:MM/dd/yyyy HH:mm}", item.End), new { @style = "width: 120px;", @class = "end" })%>

And I've tried the following to grab each of those 'MeetingList[...' items and add a datepicker to them,

        $(".start").each(function(index) {
            var $temp = $('#MeetingList[' + index + '].Start');
}); });


Working with datepicker and input controls


Helloe all,

Please I'm developing a hotel reservation system and I have both "check in" and "check out" html "input"controls and I have linked these controls to the Jquery datepicker. Unfortunately, I'm not able to access the value of the controls in asp code behind (using their ids CheckInDate and CheckOutDate respectively).

Previously, I used asp textboxes and I was able to access the IDs in code behind but whenever the page displays and I click in any of the textboxes their respective datepicker don't show.

However, I'm able to access the html input controls in code behind when I add runat="server" but when I do that the datepicker don't show for both control when I click in the input boxes.

Someone help me so that I will be able to make the datepicker show as well as fetching/accessing the value of the input boxes (selected dates) in the code behind...... or how to use asp controls and add onclick functions to call the datepicker.

Thank you.


<script type="text/javascript">
        $(function() {       
        $("#CheckInDate").datepicker({ minDate: 0, maxDate: '+1M' });

UpdatePanel - UpdateProgress only displays on initial postback



I'm having a somewhat odd issue, I'll do my best to explain it.

In a nutshell I have an UpdatePanel with an UpdateProgress item, first postback checks for warnings, if there are any they will be be displayed to the user as a JavaScript 'confirm' box. If the user clicks OK the next postback occurs to commit the change.

The UpdateProgress loading notification appears on the first postback but not on the second, even though both of them function correctly.  The buttons that trigger both postbacks are async postback triggers in the update panel, and both are inside the ContentTemplate.

It's not a huge problem, but it causes some confusion, has anybody ever seen this issue before?


Enter the date on the WPF DatePicker input textbox instead

When i type in the date on the date picker and check it on an lostfocus event and i try to read the text or selecteddate its blank?  Am i missing something.  I assumed typing in 5/11/2010 on the input box would either show up on the controls Text or the SelectedDate, but i may be missing something   Thanks

ReportViewer DatePicker Parameter - calendar not displayed when clicked

Hi, I'm using VS2008 ReportViewer control and one of my reports in SSRS 2008 R2 has a DateTime parameter. I can enter the date into the textbox and view report successfully. However the calendar is not showing when I click the calendar icon. (Note: I encounter NO error).  It seems that it's a known issue in Visual Studio. Anyone knows any workaround/hack to fix this issue? Thanks in Advance, Raymond

Initial Value for Gridview where statement

I have an web page that has a calendar on it and a gridview that is supposed to use that calendar to grab entries from the database that match the date on the calendar.  How to I get the gridview to use the inital value of the calendar (before a change is made to it) - this is typically the current date? I currently have configured the gridview to use the SelectedValue from the Calendar. Is there a command to tell the gridview to refresh? Also is there a command to have the calendar pass the whole week that the date selected falls in? -eric

custom daterange in datepicker

Hi,I have two dates (StartDate, EndDate) coming from sql database, stored in a table. How would I pass the values as a daterange to jquery datepicker?<script>         $(document).ready(function() {             $("#datepicker").datepicker({ minDate: new Date(2010, 4, 5), maxDate: new Date(2010, 8, 10) });         });   </script><script> $(document).ready(function() { $("#datepicker").datepicker({ minDate: new Date(2010, 4, 5), maxDate: new Date(2010, 8, 10) }); }); </script>Please advise.

Need urgent help using JQuery DatePicker inside asp.net user control

Hello,I am able to use the DatePicker inside an aspx page with no problem at all but when I try to use that inside a usercontrol it gives me an error "Object expected"I have the links to my Jquery css and script files from the master page and have the following code inside a usercontrol:<script type="text/javascript"><!--    $(document).ready(function() {    var txt1 = document.getElementById('<%= txtDate.ClientID %>');    $(txt1).datepicker({ dateFormat: 'dd/mm/yy', duration: ''   });    });          // --></script><asp:TextBox ID="txtDate" runat="server"></asp:TextBox>

Login error - No process is on the other end of the pipe on initial logon attempt

I am having a logon problem with asp.net apps that were created using Visual Web Developer 2008.  Data is on SQL Server Express 2008 running on Windows 2003 server with IIS6.  Connection is on a LAN.  The first time I try to log in to the site, I get the following error:Server Error in '/' Application.A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.Stack Trace:[SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No proce

WPFToolKit DatePicker VS2008 Header style

Hi, Can someone show me the quickest way to change the foreground and background colors of the header?  Thanks.

DatePicker calendar font size

Due to the fact that we have globally changed the TextBlock size, the DatePicker calendar does not display properly. The month at the top is too big and is getting cut off.   Is there a way to either override the font  size for the DatePicker to have its normal size or to directly set the size through a style? I tried this:   <Style TargetType="{x:Type CalendarItem}">     <Setter Property="TextElement.FontSize" Value="10"/> </Style>   But it didn't work. I could override the entire CalendarItem template but I'd rather not.

How do I make the DatePicker use something like a mask?

I've put my first WPF app out there for users to use.  I'm using the DatePicker control in serveal places, and at this point that's the 1 control that is giving my users the greatest headache.  With the old VB6 app that I'm trying to replace with this WPF app, the user have gotten used to entering this for a date (as an example): 09032010 Then, in my old VB6 app, it would take that and chance it to this: 09/03/2010 With the new DatePicker control in my WPF app if they enter 09032010, that's all they get.  Then when they go to save it, the app crashes badly, with an error asking if they want to send the results of the error to Microsoft, etc.  Now, so of this is stuff I've got to look into, of course.  But I know my users would like it is entering 09032010 would automatically cause it to change that to 09/03/2010.  How do I do that?  Rod

WPF ToolKit VSM: VisualStateBehaviorFactory makes memory when use DatePicker

Hi, The VisualStateBehaviourFactory in WPF Toolkit (VSM) makes memory leak when use DatePicker. In the reference path it holds the list of VisualStateBehavior instances, the VisualStateBeahvior  holds ButtonBaseBehavior and this ButtonBaseBehavior holds the CalendarButton instances. This leads the DatePicker object still alive in the memory after closing the  application that contain the DatePicker control. Try the following scenario 1. Create a window (Window1.xaml) with DatePicker control and implement the destructor for Window1  2. Then create another window (Window2.xaml) with the button to show the  Window1.xaml. 3. Now open the Window2 and click on the button 4. Now the Window1 is opened and DatePicker control displayed. 5. Close the Window1, but its destructor does not executed until close the Window2(Parent window) or it is executed after taking some time. Why? Regards, kumar

Dynamic Data Entity Framework: Initial Sort Order for Views

Hello Steve,I'm trying to set an initial sort order for my View (not table) in Dynamic Data using Entity Framework 2. I have updated my Model and Imported the View. Now I'm trying to use the DisplayColumn attibutebut it's not working.[DisplayColumn("Product", "ParsingOrder", true)]Fabio
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