jquery的时间UI出问题了貌似是ajax控件导致的 我用的是asp.net自身提供的无刷新控件,当我没点击btnsumbmit这个提交按钮的时候,txtsummarygo,txtsummaryover,txtplango,txtpalanover都能够触发弹出一个日历选择,但是我点击btnsumbmit完毕数据添加之后,要是想再添加一条信息的话,鼠标点几那4个文本框就不会弹出日历选择了,这是怎么回事呢?
代码如下<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<script>
$(function () {
$("#txtsummarygo").datepicker();
$("#txtsummaryover").datepicker();
$("#txtplango").datepicker();
$("#txtpalanover").datepicker();
});
</script>
<div style="width:100%; height:200px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummarygo" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummaryover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center" style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtsummaryinfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
</div>
<div style="width:100%; height:250px; margin-top:20px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtplango" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划结束日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtpalanover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center"style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtplaninfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
<div style="width:100%; height:30px; float:left; text-align:center;">
<asp:ImageButton ID="btnsumbmit" ImageUrl="../images/submit.gif" runat="server" style="width:74px; height:25px;" onclick="btnsumbmit_Click" /></div>
<div align="center" style="width:100%; height:20px; float:left; text-align:center;">
<div ID="p1" runat="server" style="display:none">
<div class="timgdiv"><img alt="成功" style="border:0px;" src="../images/ok.gif" /></div>
<div style="float:left; width:60px; height:14px; margin-top:2px; line-height:14px; color:Green; cursor:pointer;">添加成功!</div>
</div>
<div ID="p2" runat="server" style="display:none">
<div class="timgdiv"><img alt="错误" style="border:0px;" src="../images/err.gif" /></div>
<div style="float:left; width:150px; height:14px; margin-top:2px; line-height:14px; color:#ef4444; cursor:pointer;">提交失败,请认真填写完毕。</div>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnsumbmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
代码如下<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<script>
$(function () {
$("#txtsummarygo").datepicker();
$("#txtsummaryover").datepicker();
$("#txtplango").datepicker();
$("#txtpalanover").datepicker();
});
</script>
<div style="width:100%; height:200px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummarygo" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummaryover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center" style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtsummaryinfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
</div>
<div style="width:100%; height:250px; margin-top:20px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtplango" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划结束日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtpalanover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center"style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtplaninfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
<div style="width:100%; height:30px; float:left; text-align:center;">
<asp:ImageButton ID="btnsumbmit" ImageUrl="../images/submit.gif" runat="server" style="width:74px; height:25px;" onclick="btnsumbmit_Click" /></div>
<div align="center" style="width:100%; height:20px; float:left; text-align:center;">
<div ID="p1" runat="server" style="display:none">
<div class="timgdiv"><img alt="成功" style="border:0px;" src="../images/ok.gif" /></div>
<div style="float:left; width:60px; height:14px; margin-top:2px; line-height:14px; color:Green; cursor:pointer;">添加成功!</div>
</div>
<div ID="p2" runat="server" style="display:none">
<div class="timgdiv"><img alt="错误" style="border:0px;" src="../images/err.gif" /></div>
<div style="float:left; width:150px; height:14px; margin-top:2px; line-height:14px; color:#ef4444; cursor:pointer;">提交失败,请认真填写完毕。</div>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnsumbmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
解决方案 »
- 很简单的一个SQL语句。
- 无限极分类下拉框
- 关于:response.write 的问题,请大家帮忙看看~~~~~~``
- 寻求ASP.net高手合作
- 难道没有办法了吗?我再加分!循环添加控件!
- 菜鸟提问:怎样对文本框,下拉框进行数据绑定!
- DataList中嵌套CheckBoxList问题求助!!!
- 怎样实现文章图文混排的在先编辑,显示?
- 数据库的事务处理也Asp.net中的事务处理有什么分别,既然用了数据库的事务处理为什么还要用Asp.net中的事务?
- 那位大侠知道 如何在一个asp.net 的webform上绘图???
- 菜鸟求教 UI层用到业务层的代码都要try catch吗? 发生未处理的异常,如何让页面自动跳转到ErrPage页面呢?
- js firefox 下bug
我用jquery的ajax貌似会出错
js和jquery都是操作html标签对象的,
用来操作服务端对象就要特别注意服务端对象的ID解析成HTML标签后的变化,
同时还要注意JS的运行环境有没有变化
如果sgo接收过来的变量值是 &names 含有&这个字符就出错了 $.ajax({
type: "POST",
url: "ajax/summary.ashx",
data: 'sgo='+sgo如果用jquery的ajax来把注册信息提交到summary.ashx 就会出错了,因为含有&这个符号,
这放任何语言里都会出错的,
你不会预处理下啊....
你可以用&来代替
要不你就把
<script>
$(function () {
$("#txtsummarygo").datepicker();
$("#txtsummaryover").datepicker();
$("#txtplango").datepicker();
$("#txtpalanover").datepicker();
});
</script>
这段东西的
$(function () {});
去掉,接着把这四句话放到最后,如:<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="width:100%; height:200px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummarygo" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummaryover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center" style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtsummaryinfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
</div>
<div style="width:100%; height:250px; margin-top:20px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtplango" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划结束日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtpalanover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center"style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtplaninfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
<div style="width:100%; height:30px; float:left; text-align:center;">
<asp:ImageButton ID="btnsumbmit" ImageUrl="../images/submit.gif" runat="server" style="width:74px; height:25px;" onclick="btnsumbmit_Click" /></div>
<div align="center" style="width:100%; height:20px; float:left; text-align:center;">
<div ID="p1" runat="server" style="display:none">
<div class="timgdiv"><img alt="成功" style="border:0px;" src="../images/ok.gif" /></div>
<div style="float:left; width:60px; height:14px; margin-top:2px; line-height:14px; color:Green; cursor:pointer;">添加成功!</div>
</div>
<div ID="p2" runat="server" style="display:none">
<div class="timgdiv"><img alt="错误" style="border:0px;" src="../images/err.gif" /></div>
<div style="float:left; width:150px; height:14px; margin-top:2px; line-height:14px; color:#ef4444; cursor:pointer;">提交失败,请认真填写完毕。</div>
</div>
</div>
</div>
<script>
$("#txtsummarygo").datepicker();
$("#txtsummaryover").datepicker();
$("#txtplango").datepicker();
$("#txtpalanover").datepicker();
</script>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnsumbmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<ContentTemplate>
<div style="width:100%; height:200px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummarygo" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">总结开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtsummaryover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center" style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtsummaryinfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
</div>
<div style="width:100%; height:250px; margin-top:20px; float:left;">
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划开始日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtplango" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div style="width:25%; height:30px; text-align:right; line-height:30px; float:left;">计划结束日时间:</div>
<div style="width:25%; height:30px; float:left;"><asp:TextBox ID="txtpalanover" style="width:95%; margin-top:4px; border:solid #6293bb 1px;" runat="server"></asp:TextBox></div>
<div align="center"style="width:100%; height:160px; float:left;"><asp:TextBox ID="txtplaninfo" TextMode="MultiLine" MaxLength="300" style="width:95%; height:150px;" runat="server"></asp:TextBox></div>
<div style="width:100%; height:30px; float:left; text-align:center;">
<asp:ImageButton ID="btnsumbmit" ImageUrl="../images/submit.gif" runat="server" style="width:74px; height:25px;" onclick="btnsumbmit_Click" /></div>
<div align="center" style="width:100%; height:20px; float:left; text-align:center;">
<div ID="p1" runat="server" style="display:none">
<div class="timgdiv"><img alt="成功" style="border:0px;" src="../images/ok.gif" /></div>
<div style="float:left; width:60px; height:14px; margin-top:2px; line-height:14px; color:Green; cursor:pointer;">添加成功!</div>
</div>
<div ID="p2" runat="server" style="display:none">
<div class="timgdiv"><img alt="错误" style="border:0px;" src="../images/err.gif" /></div>
<div style="float:left; width:150px; height:14px; margin-top:2px; line-height:14px; color:#ef4444; cursor:pointer;">提交失败,请认真填写完毕。</div>
</div>
</div>
</div>
<script>
function initDatepicker()
{
$("#txtsummarygo").datepicker();
$("#txtsummaryover").datepicker();
$("#txtplango").datepicker();
$("#txtpalanover").datepicker();
};
$(document).ready(function() {
initDatepicker();
});
</script>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnsumbmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>后台代码,在btnsumbmit_Click事件最后加入ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "initDateControl", "initDatepicker();", true);