JQuery DatePicker Not Saving Correct Dates On Partial Postback

Jun 23, 2010

I have some textboxes (in an UpdatePanel in a ModalPopup in a User Control) that look like this:

<asp:TextBox ID="exampleTextBox" runat="server" MaxLength="10"
CssClass="datepicker" ReadOnly=true
Text='<%# Bind("ExampleDateField") %>' Width="77px">
</asp:TextBox>

I also have some jQuery (imported from file on the Master page) that hooks up the jQuery DatePickers like so:

function pageLoad() {
$(".datepicker").unbind();
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
beforeShowDay: $.datepicker.noWeekends,
showOn: 'button',
buttonImage: '../Resources/Images/Calendar_scheduleHS.gif',
buttonImageOnly: true,
buttonText: 'Select a Date'
});
}

The DatePickers appear correctly, even after a postback. The problem is that the value of the textboxes is not changed when a postback occurs. This is very odd since the textbox shows the selected date in the browser. However, the value of the textbox is still the date that the textbox originally had, not the date selected from the datepicker.

View 1 Replies


Similar Messages:

Jquery Datepicker Not Focused After Date Is Chosen, After Postback Datepicker Doesn't Work

Jan 25, 2011

everytime the user selects a date from my datepicker the for some reason instead of staying focused on the are the date picker is in it scrolls to the top of the page.

Heres the function located at the bottom of my asp.net page under the

<script>
$(function() {
$( "#<%= pissued1.ClientID %>" ).datepicker();
});
</script>

This is the code.

<td align="left" colspan="2">
<strong>
<asp:Label ID="labdi1" runat="server" Text="*Date Issued:"></asp:Label>
<asp:RequiredFieldValidator ID="p1divalidate" runat="server" ControlToValidate="pissued1"
ErrorMessage="You Forgot The">*</asp:RequiredFieldValidator><br />
</strong>
<asp:TextBox ID="pissued1" runat="server" Width="45%"></asp:TextBox>
</td>

and also on postback my datepickers stop working. For example i have a dropdownlist that causes postback and if the user uses the drop downlist then the datepickers stop working

View 1 Replies

Disable Dates In Jquery Datepicker

Sep 23, 2010

I am using a jquery datepicker and timepicker. In datepicker I want to disable the all dates which are past to the current date. And in timepicker I want to show the times which is one hour prior to the current time.Can anyone tell me how to do this?

View 2 Replies

AJAX :: Populate DatePicker With Dates From JQuery

May 7, 2015

protected void Page_Load(object sender, EventArgs e) {
Session["ID"] = "2";
string strConnString = ConfigurationManager.ConnectionStrings["BSDConnectionString"].ConnectionString;
var con = new SqlConnection(strConnString);
using (var sda = new SqlDataAdapter()) {
SqlCommand cmd = new SqlCommand();

[Code] .....

That was my code , now lets see what my problem is :

I am getting only two dates in a single row from sql to my asp.net webform and then bindng those dates in jQuery UI Datepicker. Now if i set session to 1 then date picker works well but if i put session = 2 , it shows the end date till 2020 which is wrong.

Below are the dates which are fetched from database and i have copied here....

When Session["ID"] = "1";

Start Date : 01/07/2014 00:00:00
End Date :   05/02/2015 00:00:00   

When Session["ID"] = "2";

Start Date : 07/04/2015 00:00:00
End Date :   27/08/2016 00:00:00      

I have set my mindate to startdate and maxdate to end date....

Also point of interest is that if i don't fetch values from database and use only List<string> in my web method then every thing works well. Like this :

[WebMethod]
public static List<string> GetDates() {
List<string> arr = new List<string>();
arr.Add("2014-07-01");
arr.Add("2015-02-05");
return arr;
}

View 1 Replies

Display Server Side Dates In Jquery Datepicker?

Feb 18, 2011

i have a textbox1 in my asp.net webform which shows the server side date : i want the user would not select date using jquery datepicker earlier than the date in the textbox1 i m using the following code to show jquery calendar in other textbox2 :

<link href="./themes/sunny/jquery.ui.all.css" rel="stylesheet" type="text/css"/>
<link href="./themes/sunny/jquery.ui.all.css" rel="stylesheet" type="text/css"/>
<script src="./js/jquery.min.js"></script>
<link rel="stylesheet" href="./demos/demos.css">
<script src="./js/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".datepicker").datepicker({
buttonText: 'Select date:',
firstDay: 1,
buttonImage: "./demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
showOn: 'both',
showAnim: 'fadeIn',
minDate: '0',
dateFormat: 'dd-M-yy',
onSelect: function() { $(this).trigger("onchange", null); }
});
});
</script>

View 1 Replies

MVC :: Using Tabs With Partial Views And Want To Render The Correct One After A Postback?

Nov 22, 2010

I am using tabs and I want some user input on each one.hen I click submit I return the partial view. However it is only the partial view that gets rendered.What I am trying to do is keep the overall view and render the partial view. In fact what I am trying to do is known as hijaxing, but I am not familiar enough with Ajax that I know how to do it.So this is my view;

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Employee.Master" Inherits="System.Web.Mvc.ViewPage<SHP.WebUI.Models.HolidayRequestViewModel>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> HolidayRequest</asp:Content><asp:Content
ID="Content2" ContentPlaceHolderID="EmployeeContent" runat="server"> <% using (Html.BeginForm()) {%> <%: Html.AntiForgeryToken() %> <h2>Holiday Request</h2> <p>You have <%: Html.DisplayFor(model => model.DaysAvailableThisYear) %> days left annual leave for this year and <%: Html.DisplayFor(model => model.DaysAvailableNextYear) %> days left for next year.</p> <p>If your request is approved and exceeds the number of days left, then those extra days will not be paid.</p> <%: Html.HiddenFor(x => x.EmployeeId) %><%: Html.HiddenFor(x => x.ApproverId) %> <% } %> <div id="tabs"> <ul> <li><a href="#tabs-1">Approver</a></li> <li><a href="#tabs-2">Single Date</a></li> <li><a href="#tabs-3">Date Range</a></li> </ul> <div id="tabs-1"> <% Html.RenderPartial("GetApproverTab", Model); %> </div> <div id="tabs-2"> <% Html.RenderPartial("GetSingleDateTab", Model); %> </div> <div id="tabs-3"> <% Html.RenderPartial("GetDateRangeTab", Model); %> </div> </div></asp:Content>
This is my partial view;
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SHP.WebUI.Models.HolidayRequestViewModel>" %><% using (Html.BeginForm("GetSingleDateTab", "Employee", FormMethod.Post, new { id = "frmSingleDate" }))&nbsp; &nbsp; &nbsp; &nbsp;{ %><p>Enter your day or part day of Annual Leave here.</p><table> <tr> <td align="right">Date:</td> <td><%: Html.EditorFor(x => x.SingleDate) %></td> </tr> <tr> <td align="right">Morning Only:</td> <td><%: Html.CheckBoxFor(x => x.MorningOnlyFlag) %></td> </tr> <tr> <td align="right">Afternoon Only:</td> <td><%: Html.CheckBoxFor(x => x.MorningOnlyFlag) %></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Save" /></td> </tr></table><%: Html.HiddenFor(x => x.EmployeeId) %><%: Html.HiddenFor(x => x.ApproverId) %> <% } %>

and this is my controller;

View 7 Replies

Textbox With Jquery Ui Datepicker Value Lost When Doing A Postback?

Mar 10, 2011

I've got an application that uses jquery ui datepicker on an asp.net textbox control.The control is working as intended, but I've noticed that when you postback from a server call (via submit button), the entered value gets lost in the application.Was wondering if you all have experienced this? And what measures that you have to do to prevent this?Here is my code:HTML:

<asp:TextBox runat="server" ID="txtCallsMadeFrom" class="field" EnableViewState="true">

JQuery:

var callsMadeFromId = '#<%=txtCallsMadeFrom.ClientID %>';
jQuery(callsMadeFromId).datepicker({ showOn: "button", buttonImage: "../images/calendar.gif", altFormat: 'dd/mm/yy', buttonImageOnly: true, onSelect: function () { } });

View 2 Replies

JQuery :: TextboxWaterMarkExtender And Datepicker - TextBox Losing Value On PostBack?

Feb 25, 2011

I have a textbox that uses TextboxWaterMarkExtender and jquery-ui's datepicker plugin.Upon postback, my textbox is losing the value selected from jquery datepicker.Below is the sample code to see the behavior. Is there anyway I can make my textbox to retain selected value on postback?One thing to note is, if I use jquery watermark plugin, it does postback the value. But for certain reasons, I think I plan to use AjaxControlToolkit.

[Code]....

View 2 Replies

C# - JQuery Is Not Working After Partial Postback?

Aug 25, 2010

I have this jquery functions below in external file. So after partial postback jquery is not working. I need to load jquery from server side on partial postback.

can someone show me what I need to call in this code and how to load jquery

[Code].....

View 2 Replies

JQuery :: How To Save State Of A Toggle Button After Partial Postback

Oct 7, 2010

lets say you have the toggle buttons from this page: [URL]

and you put it in a UpdatePanel AJAX... so lets say on a partialpostback.. when you re-create teh controls on server-side, the state of whether or not those buttons were pushed is long-lost and gone.. so how then how do you remember those states?

Can I save each button state into viewstate or session state? regenerate each button then call the javascript function to change its color-state depending on the session state variable?

View 2 Replies

AJAX :: JQuery MultiSelect DropDownList With CheckBoxes Not Working After UpdatePanel Partial PostBack?

May 7, 2015

In my previous question mentioned below.

My previous question mentioned

[URL]

Now i am having two dropdown one is asp dropdownlist and 2ND is MultiSelect-DropDownList-with-CheckBoxes. 2nd dropdown is populating on selected value of first.On page load it works fine. Now, on change of value in dropdown, selected index change 2nd dropdown (MultiSelect-DropDownList-with-CheckBoxes) fills but i see a list box instead of dropdown.

View 1 Replies

JQuery Datepicker Not Working / Want To Add The JQuery Datepicker To The UI

Jun 10, 2010

I'm completely new to JQuery and MVC. I'm working on a pet project that uses both to learn them and I've hit my first snag.

I have a date field and I want to add the JQuery datepicker to the UI. Here is what I have done:

Added <script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
to the site.master

Inside my Create.aspx (View), I have

<asp:Content ID="Create" ContentPlaceHolderID="MainContent" runat="server">
<h2>
Create a Task</h2>
<% Html.RenderPartial("TaskForm"); %>
</asp:Content>

and inside "TaskForm" (a user control) I have:

<label for="dDueDate">
Due Date</label>
<%= Html.TextBox("dDueDate",(Model.Task.TaskID > 0 ? string.Format("{0:g}",Model.Task.DueDate) : DateTime.Today.ToString("MM/dd/yyyy"))) %>
<script type="text/javascript">
$(document).ready(function() {
$("#dDueDate").datepicker();
});
</script>

As you can see, the above checks to see if a task has an id > 0 (we're not creating a new one) if it does, it uses the date on the task, if not it defaults to today. I would expect the datepicker UI element to show up, but instead I get:

"Microsoft JScript runtime error: Object doesn't support this property or method" on the $("#dDueDate").datepicker();

It is probably a very simple mistake, so don't over-analyze. As I said, this is the first time I've dealt with MVC or JQuery so I'm lost as to where to start.

View 3 Replies

AJAX :: Calendar Extender Not Saving Dates?

Apr 13, 2010

I am quite new to the toolkit and have run into a problem where I have an ASPX page with 3 textboxes linked to calendar extenders. I have a ImageButton to populate the textboxes with the date, but the 2 problems occur:1. The date appears correct in the textboxes, but I am getting an error saying a sting to date conversion error occured.2. When saving my data using the UATDate_CalendarExtension.SelectedDate value, the date in the text box is not saved, it keeps the previously saved date.

View 3 Replies

MVC :: Saving Data From Partial Views?

Nov 5, 2010

I have an "Instruction" view, which have partial views for entering instruction details, different attributes for the instruction, different input values etc for the instruction. Each of which is seperate partial view. The main view have a save button which save all these details. "InstructionDetails" partial view have instruction name, description and its model is "Instruction". "Attribute" partial view have dropdown to select attribute and a textbox to enter its value. It also has an button "Add to list" which is intended to add attribute details to a table which is in the same partial view for attribute, its model is "Attribute". Same is the senario with input values. I have few problems where i am struck up with.When the "Add to list" is clicked in Attribute partial view, the values from the dropdown and textbx need to be listed to the table.When "Save" button is clicked the entire view need to be saved.

View 2 Replies

JQuery :: Greater And Less Than Date With JQuery And DatePicker In MVC?

Oct 7, 2010

I have this date value fetch from a Controller but when I use jQuery Datepicker with validation, the output is not good.The validation is to check if the value is less than or greater than today's date. JQuery Datepicker works well.If I select a date two days from now using datepicker, the validation error won't occur. [:(]

ViewData("DateToday") = Date.Now.ToShortDateString()
<link href="/css/jQuery/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>

[code]....

View 2 Replies

MVC :: Filtering Data In Partial View Based On Datepicker On View?

Mar 6, 2011

I have added a jquery datepicker on my MVC view. This view has a partial view. I need to filter my partial view based on the datepicker's selected date. I need to show buttons on partial view based on the date.

I have added partial view like this:

div id="dvGames" class="cornerdate1"> % Html.RenderPartial("Partial3"); %>
/div>

View 5 Replies

JQuery :: How To Use Jquery Datepicker As Usercontrol

Nov 18, 2010

I am new for Jquerry,I have a user control with a Jquerry calender control,but i am geting "Microsoft JScript runtime error: Object expected" this error when i m trying to add in .aspx page.

can anybody suggest the solution:

.ascx Page:

<script type="text/javascript" src="~/js/jquery-1.3.1.min.js"></script>
<script src="~/js/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>
<script src="~/js/daterangepicker.jQuery.js" type="text/javascript"></script>
<link href="~/css/ui.daterangepicker.css" rel="stylesheet" type="text/css" />
<link href="~/css/redmond/jquery-ui-1.7.1.custom.css" rel="stylesheet" type="text/css" />
<script type=text/javascript>
Calender()
{
$(function() {
$("#<%= TextBox1.ClientID %>").attr("readonly", "readonly");
$("#<%= TextBox1.ClientID %>").attr("unselectable", "on");
// $("#<%= TextBox1.ClientID %>").daterangepicker({ presetRanges: [], arrows: true, dateFormat: 'd M, yy', clearValue: '', datepickerOptions: { changeMonth: true, changeYear: true} });
$("#<%= TextBox1.ClientID %>").daterangepicker({arrows: true, dateFormat: 'd M, yy', clearValue: '', datepickerOptions: { changeMonth: true, changeYear: true} });
}
);
}
</script>
<asp:TextBox ID="txtDateOfBirth" runat="server"
Width="82%" BorderColor="#f4785e" TabIndex="-1"></asp:TextBox>
------------------------------------------------------
UI.aspx:
<uc3:AgeCalUsercontrol ID="AgeCalUsercontrol1" runat="server" />

View 5 Replies

JQuery :: Is It Possible To Use Asp:Textbox For JQuery Datepicker

Oct 27, 2010

is it possible to use asp:Textbox for JQuery Datepicker?

View 2 Replies

JQuery :: How To Add Datepicker In Code Behind

Dec 10, 2010

how to add Datepicker in code behind

[Code]....

View 16 Replies

Use JQuery DatePicker On Textbox?

Nov 25, 2010

I am new to JQuery and want to know how to attach DatePicker to textbox.

View 3 Replies

JQuery :: Get DatePicker Plug In?

Oct 10, 2010

Is there an easy way to get the datePicker plugin? Currently, I include the following jquery in a web page: [Code]....

At the jquery site, the download for datePicker has a bunch of files. And I am confused by the instructions. Went to another site for datePicker, and I get "object not supported" errors.Is there a simple "jquery-latest-UI.js" file I can include in the web page?

View 3 Replies

JQuery :: Use DatePicker Within DataGrid?

Mar 30, 2011

I am using VS2005

I have got a Datagrid which has got a textbox in a cell in each row. How can I use the jQuery datepicker with the textbox?

View 6 Replies

JQuery :: Datepicker Has No Style?

Aug 18, 2010

My date picker has no style as in it doesnt seem to be recognising the style sheet

[Code]....

and my html

[Code]....

View 2 Replies

JQuery :: Popout Datepicker From Textbox

Oct 21, 2010

i have a simple asp.net textbox. can someone provide me with an example so that when the user clicks inside the textbox, a jquery datepicker popsout? also, i need it so that when the user clicks a date in the datepicker, the textbox is populated with this date.

View 6 Replies

JQuery Datepicker Not Working In Page?

Feb 25, 2011

I am using ASP.NET to develop a website and I am going to use the jQuery datepicker in my website. I used following code, but it won't work. Does anyone know why?

<link href="css/calendar/jquery-ui-1.8.7.custom.css" rel="stylesheet" type="text/css" />
<script src="jquery/calendar/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="jquery/calendar/jquery-ui-1.8.7.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#txtEventDate").datepicker();
});
</script>

Here is my textbox HTML code:

<asp:TextBox ID="txtEventDate" runat="server" Width="125px"></asp:TextBox>

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved