求救 ASP.NET,C#,JQuery
时间:2013-11-09
来源:互联网
我想 从Datalist搵TextBox的ID,然后放入JQuery DatePicker,但系执行后发现variable:lease 系undefined
我希望有人能够帮帮手,谢谢!! Reference website:
如果我的Datalist 一开始是没有DATA, error会显示:"lease" is not in the current context, 这与Datalist 没有任何资料有关吗?
Source Code
html)<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/><script src="http://code.jquery.com/jquery-1.9.1.js"></script><script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript">
$(function() {
var lease = $('#<%= edit_period_list.ClientID %>').find('input:text[id$="edit_lease_from"]').val(); (lease = undefined)
var holiday = ["12/24/2012","12/25/2012"];
$("#<%= from.ClientID %>, lease").datepicker({
setDate: 'dd/mm/yy',
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
minDate: "-5y",
maxDate: "+5y",
beforeShowDay: function (date) {
if (date.getDay() == 0 || date.getDay()== 6)
{ return [false, '', '']; } //No Weekends
for (var i = 0; i < holidays.length;i++) {
if (new Date(holidays).toString() ==date.toString())
{ return [true, 'Highlight', '']; } //NoHolidays
}
return [true, ''];
}
});
});
</script><asp:TextBox ID="from" runat="server"AutoPostBack="True"
></asp:TextBox> <--没问题
<asp DataListID="edit_period_list" runat="server"DataKeyField="period_id"
DataSourceID="edit_period_data"
>
<ItemTemplate>
<tableborder="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; width:1135px;">
<tr>
<td class="one">
<asp:TextBoxID="edit_lease_from" runat="server"
Text='<%#Eval("lease_from","{0:dd/MM/yyyy}") %>' ></asp:TextBox>
</td>
<td class="two">
<asp:TextBoxID="edit_lease_to" runat="server"
Text='<%#Eval("lease_to","{0:dd/MM/yyyy}") %>' ></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</aspDataList> $(function() { var lease = $('#<%= edit_period_list.ClientID %>').find('input:text[id$="edit_lease_from"]').val(); (lease = undefined) var holiday = ["12/24/2012","12/25/2012"]; $("#<%= from.ClientID %>, lease").datepicker({ setDate: 'dd/mm/yy', dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, minDate: "-5y", maxDate: "+5y", beforeShowDay: function (date) { if (date.getDay() == 0 || date.getDay()== 6) { return [false, '', '']; } //No Weekends for (var i = 0; i < holidays.length;i++) { if (new Date(holidays).toString() ==date.toString()) { return [true, 'Highlight', '']; } //NoHolidays } return [true, '']; } });}); <--没问题 [table=98%]<asp:textboxid="edit_lease_from"[ color]="" runat="server" [="" size][="" font]="" " text=""> <asp:textboxid="edit_lease_to" runat="server" [="" size][="" font]="" " text="">
[ 本帖最后由 saturn1022 於 2013-9-12 08:05 PM 编辑 ]
我希望有人能够帮帮手,谢谢!! Reference website:
如果我的Datalist 一开始是没有DATA, error会显示:"lease" is not in the current context, 这与Datalist 没有任何资料有关吗?
Source Code

$(function() {
var lease = $('#<%= edit_period_list.ClientID %>').find('input:text[id$="edit_lease_from"]').val(); (lease = undefined)
var holiday = ["12/24/2012","12/25/2012"];
$("#<%= from.ClientID %>, lease").datepicker({
setDate: 'dd/mm/yy',
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
minDate: "-5y",
maxDate: "+5y",
beforeShowDay: function (date) {
if (date.getDay() == 0 || date.getDay()== 6)
{ return [false, '', '']; } //No Weekends
for (var i = 0; i < holidays.length;i++) {
if (new Date(holidays).toString() ==date.toString())
{ return [true, 'Highlight', '']; } //NoHolidays
}
return [true, ''];
}
});
});
</script><asp:TextBox ID="from" runat="server"AutoPostBack="True"
></asp:TextBox> <--没问题
<asp DataListID="edit_period_list" runat="server"DataKeyField="period_id"
DataSourceID="edit_period_data"
>
<ItemTemplate>
<tableborder="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; width:1135px;">
<tr>
<td class="one">
<asp:TextBoxID="edit_lease_from" runat="server"
Text='<%#Eval("lease_from","{0:dd/MM/yyyy}") %>' ></asp:TextBox>
</td>
<td class="two">
<asp:TextBoxID="edit_lease_to" runat="server"
Text='<%#Eval("lease_to","{0:dd/MM/yyyy}") %>' ></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</aspDataList> $(function() { var lease = $('#<%= edit_period_list.ClientID %>').find('input:text[id$="edit_lease_from"]').val(); (lease = undefined) var holiday = ["12/24/2012","12/25/2012"]; $("#<%= from.ClientID %>, lease").datepicker({ setDate: 'dd/mm/yy', dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, minDate: "-5y", maxDate: "+5y", beforeShowDay: function (date) { if (date.getDay() == 0 || date.getDay()== 6) { return [false, '', '']; } //No Weekends for (var i = 0; i < holidays.length;i++) { if (new Date(holidays).toString() ==date.toString()) { return [true, 'Highlight', '']; } //NoHolidays } return [true, '']; } });}); <--没问题 [table=98%]<asp:textboxid="edit_lease_from"[ color]="" runat="server" [="" size][="" font]="" " text=""> <asp:textboxid="edit_lease_to" runat="server" [="" size][="" font]="" " text="">
[ 本帖最后由 saturn1022 於 2013-9-12 08:05 PM 编辑 ]
作者: saturn1022 发布时间: 2013-11-09
系 data list 里面,根本唔会有呢个 edit_lease_from 的 ID。你用 view source 睇下就知。
Datalist 里面有好多 item,都唔会只有一个 edit_lease_from,会唔会 logic 根本上有问题。
Datalist 里面有好多 item,都唔会只有一个 edit_lease_from,会唔会 logic 根本上有问题。
作者: pc_chai 发布时间: 2013-11-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28