页面上的多个更新面板从文本框中删除 JavaScript Datepicker 日历

发布于 2024-09-26 03:07:44 字数 595 浏览 1 评论 0原文

实际上,我在页面上有多个更新面板,它们更新服务器上的不同值,但问题是我有一个文本框,我在加载事件上附加了日期选择器的 javascript 类。

但是在该日期文本框之前还有其他更新面板,当我更新它们时,更新面板中带有日期控件的第一个日历图像消失了。或者删除文本框旁边的日历。

txtDate.Attributes.Add("class", "show-week w16em dateformat-d-sl-m-sl-Y"); 

在使用任何 updatepanel 之前,它像这样

alt text

在我们更新任何 updatepanel 控件之后,它像这样。

alt text

但是不在任何 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

alt text

After we upfdate any updatepanel control its like this.

alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

枕梦 2024-10-03 03:07:44

我猜日期选择器及其文本框都放置在更新面板中?

如果您使用 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).

总攻大人 2024-10-03 03:07:44

您是否更改了文本框所在的 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.

少女情怀诗 2024-10-03 03:07:44

无论您使用什么方法附加日期选择器,您都必须在 updatepanel 更新后再次调用,

您可以使用 this

// at some point of the method that updates the panel
ScriptManager.RegisterStartupScript(
    this, typeof(object), "someUniqueKey", "theScript();", true);

或在客户端使用以下内容:

// <body onload='...'> or in the <head>
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
    function () { theScript() });

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:

// at some point of the method that updates the panel
ScriptManager.RegisterStartupScript(
    this, typeof(object), "someUniqueKey", "theScript();", true);

or on client side with this:

// <body onload='...'> or in the <head>
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
    function () { theScript() });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文