Answered by:
how to pass label value in jquery min date

Question
-
User-807418713 posted
Hello
On load my Label1 Shows 40 for example
Then i want to pass this label1 to this jquery calendar minDate: -0, jquery
$(document).ready(function() { $("#EnterDate").datepicker({ dateFormat:"dd-mm-yy", minDate: -0, maxDate: "+0M +4D" }); });
how to do so using asp.net 2.0 C#
Thank You
Sunday, September 16, 2018 7:53 AM
Answers
-
User-1171043462 posted
This way
<asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox> <asp:Label ID="lblMinDate" Text="-M0 -4D" runat="server" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script> <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" /> <script type="text/javascript"> $(function () { $("[id*=txtDate]").datepicker({ dateFormat: "dd-mm-yy", minDate: $("[id*=lblMinDate]").html(), maxDate: "+0M +4D" }); }); </script>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 18, 2018 11:22 AM
All replies
-
User475983607 posted
how to do so using asp.net 2.0 C#Confused... your post is contradictory. I assume you successfully set the Text property of label1 in the code behind. This would be done in asp.net 2.0 C#. Now you want to get that value using a jQuery selector.
The syntax is shown below and assumes there is only one Label1 server control on the web form.
$(document).ready(function() { $("#EnterDate").datepicker({ dateFormat:"dd-mm-yy", minDate: $('#<%=Label1.ClientID%>').text(), maxDate: "+0M +4D" }); });
jQuery Selectors
https://api.jquery.com/category/selectors/
jQuery $.text()
Control.ClientID
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.control.clientid?view=netframework-4.7.2
Sunday, September 16, 2018 1:19 PM -
User-807418713 posted
Hello
On F12 My control ID showing like this
ctl00_ContentPlaceHolder1_Label10
How to insert this in mindate
Tuesday, September 18, 2018 7:55 AM -
User475983607 posted
Read my previous thread. Visit the links and read them as well.Tuesday, September 18, 2018 10:37 AM -
User-1171043462 posted
This way
<asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox> <asp:Label ID="lblMinDate" Text="-M0 -4D" runat="server" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script> <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" /> <script type="text/javascript"> $(function () { $("[id*=txtDate]").datepicker({ dateFormat: "dd-mm-yy", minDate: $("[id*=lblMinDate]").html(), maxDate: "+0M +4D" }); }); </script>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 18, 2018 11:22 AM