页面上的多个更新面板从文本框中删除 JavaScript Datepicker 日历
实际上,我在页面上有多个更新面板,它们更新服务器上的不同值,但问题是我有一个文本框,我在加载事件上附加了日期选择器的 javascript 类。
但是在该日期文本框之前还有其他更新面板,当我更新它们时,更新面板中带有日期控件的第一个日历图像消失了。或者删除文本框旁边的日历。
txtDate.Attributes.Add("class", "show-week w16em dateformat-d-sl-m-sl-Y");
在使用任何 updatepanel 之前,它像这样
在我们更新任何 updatepanel 控件之后,它像这样。
但是不在任何 updatepanel 中的日期控件都可以正常工作。
在这些 updatepanels 中,我实际上将值保存在 DataTables 中,并将这些 DataTables 保存在 viewState 中...... HTML 没有变化。
Actually I have Multiple update panels on page, which update different values on server but the problem is that I have textbox to which I attach javascript class for datepicker on Load event.
But There are other updatepanels before that date TextBox, when I update them first calender image with date control which is in updatepanel disappears. or it remove the calender which is next to the textbox.
txtDate.Attributes.Add("class", "show-week w16em dateformat-d-sl-m-sl-Y");
Before using any updatepanel its like this
After we upfdate any updatepanel control its like this.
But the Date controls which are not in any updatepanel are ok and working.
And in these updatepanels I actually saving values in DataTables and save these DataTables in viewState .... no change in HTML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我猜日期选择器及其文本框都放置在更新面板中?
如果您使用 UpdatePanel 进行 ajax 回发,服务器将为页面上的所有 UpdatePanel 发送回 html,并刷新其所有内容,因此您的日期选择器将消失。
如果您在 UpdatePanel 上设置
UpdateMode=Conditional
,则只有导致回发的 UpdatePanel 才会更新。另一种选择是使用 ScriptManager.RegisterStartupScript 重新创建日期选择器,但这可能会重置其值(取决于它是哪个日期选择器)。
I guess the datepicker and its textbox both are placed in an updatepanel?
If you do an ajax-postback with UpdatePanels the server will send html back for all UpdatePanels on the page, and refresh all of their contents, so your datepicker will disappear.
If you set
UpdateMode=Conditional
on the UpdatePanels then only the UpdatePanels that caused the postback will update.Another option is to recreate the datepicker with ScriptManager.RegisterStartupScript, but this possibly resets its value (depends on which datepicker it is).
您是否更改了文本框所在的 DIV 或 TABLE 的 INNERHTML,因为如果您要在更新 DIV 或 TABLE 后删除日历控件。
Are you changing the INNERHTML of the DIV or TABLE in which the TextBox is present because if you are then its removing the calender control after that DIV or TABLE is being updated.
无论您使用什么方法附加日期选择器,您都必须在 updatepanel 更新后再次调用,
您可以使用 this:
或在客户端使用以下内容:
whatever method you are using to attach the datepicker, you must call again after the updatepanel updates
you can do it on server side with this:
or on client side with this: