RadDatePicker SelectedDateChanged issue
本文关键字:issue SelectedDateChanged RadDatePicker | 更新日期: 2023-09-27 18:11:57
我有RadDatePicker控件与SelectedDateChanged事件。当我更改日期时,事件会触发确认窗口。当我点击"取消"按钮RadDatePicker1_SelectedDateChanged再次调用,它显示确认窗口两次。当我点击"确定"按钮,它工作得很好。有什么问题吗?谢谢你的建议。
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" AutoPostBack="true" OnSelectedDateChanged="RadDatePicker1_SelectedDateChanged" >
</telerik:RadDatePicker>
protected void RadDatePicker1_SelectedDateChanged(object sender, EventArgs e)
{
string radalertscript = "<script language='javascript'>function f(){ radconfirm('Are you sure?', confirmChange, 400, 100) ; Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert33", radalertscript);
}
这是Javascript函数
function confirmChange(args) {
if (args) {
__doPostBack("<%= hiddenButton1.UniqueID %>", "");
}
如果你只是用它来渲染一些javascript,这似乎是一个不必要的回发。
你能在客户端进行确认对话吗?
http://www.telerik.com/help/aspnet-ajax/calendar-on-date-selecting.html<script type="text/javascript">
function ConfirmChange(sender, eventArgs) {
var date = eventArgs.get_renderDay().get_date();
var dfi = sender.DateTimeFormatInfo;
var formattedDate = dfi.FormatDate(date, dfi.ShortDatePattern);
eventArgs.set_cancel(!confirm("Are you sure you want to " +
(eventArgs.get_isSelecting() ? "select " : "unselect ") +
formattedDate + "?"));
}
</script>
<telerik:RadCalendar ID="RadCalendar1" runat="server">
<ClientEvents OnDateSelecting="ConfirmChange" />
</telerik:RadCalendar>