简体   繁体   English

Ajax Toolkit Calendar Extender,选择后弹出两次

[英]Ajax Toolkit Calendar Extender, Pops up twice after selection

I am having very strange issue. 我有一个很奇怪的问题。 I am using the Ajax Toolkit Calendar Extender. 我正在使用Ajax工具包日历扩展程序。 I have Update Panel - > ListView -> TextBox (AutoPostBack=Yes). 我有更新面板-> ListView->文本框(AutoPostBack =是)。 If I type in box it will update to db then do update panel using code behind updatepanel.update(). 如果我在框中输入内容,它将更新为db,然后使用updatepanel.update()后面的代码进行更新面板。 This works fine. 这很好。 So I want to put calendar in the text field so I use Ajax Calendar Extender and call the target control ID of the textbox and when I am in there I click the textbox and calendar pops up then I choose date and textbox changes to new date then updates to db then postbacks, but the problem is the calendar pops up again after the postback. 因此,我想将日历放在文本字段中,以便使用Ajax Calendar Extender并调用文本框的目标控件ID,然后在其中单击文本框并弹出日历,然后选择日期并将文本框更改为新日期先更新到db,然后再进行回发,但是问题是日历在回发后再次弹出。 I need a way to hide that damn calendar after selecting date the first time. 我需要一种在第一次选择日期后隐藏该死日历的方法。

<asp:TextBox ID="txtDespatchDate" runat="server" CssClass="tblDespContTxtLst" Text='<%# Eval("DescDespatchDate") %>' Width="70px" AutoPostBack="True" OnTextChanged="updDespatchLine" AutoComplete="Off" />

<ajaxToolkit:CalendarExtender ID="calDespatchDate" runat="server" CssClass="Calendar" Format="dd/MM/yyyy" PopupPosition="BottomLeft" TargetControlID="txtDespatchDate"  />

I figured this one out a long time ago, and being on a server and all and doing postbacks I couldnt get around it using the ajax extender, so I have to use JQuery, I did something like this; 我很早以前就想出了这一点,并且在服务器上进行所有工作并进行回发,所以我无法使用ajax扩展器解决它,所以我必须使用JQuery,我做了类似的事情;

Code Behind 背后的代码

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   ScriptManager.RegisterStartupScript(NameOfUpdatePanel, Me.GetType, "SuperCalendar", "$( function() {
      $('.Calendar').datepicker({ dateFormat: 'dd/mm/yy'}); } );", True)
End Sub

ASP Page ASP页面

<asp:UpdatePanel ID="NameOfUpdatePanel" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
      <asp:TextBox ID="txtBox1" runat="server" CssClass="Calendar" />
   </ContentTemplate>
</asp:UpdatePanel>

You need to add the latest JQuery Header to the top of your page like; 您需要将最新的JQuery标头添加到页面顶部,例如:

<script src="../Scripts/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>

All you have to do is every time you want a date popup you just add the Calendar Class to it so; 您要做的就是每次您想要一个日期弹出框时,只需将Calendar Class添加到其中;

CssClass="SomeTextBoxClass Calendar"

I dont get any problems after postbacks with it popping up anymore. 回发后,它弹出时我没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM