客户端确认后的下拉列表自动回传 [英] DropdownList autoposback after client confirmation

查看:22
本文介绍了客户端确认后的下拉列表自动回传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自动回发设置为 true 的下拉列表.我想要用户确认他们是否真的想要更改值,在回发时触发服务器端事件(selectedindexchanged).

I have a dropdownlist with the autopostback set to true. I want the user to confirm if they really want to change the value, which on post back fires a server side event (selectedindexchanged).

我尝试添加一个 onchange 属性返回确认('请单击确定进行更改.否则单击取消?';")但无论确认如何,它都不会回发如果取消,结果和列表中的值不会恢复被选中.

I have tried adding an onchange attribute "return confirm('Please click OK to change. Otherwise click CANCEL?';") but it will not postback regardless of the confirm result and the value in the list does not revert back if cancel selected.

当我从 DropdownList 标记中删除 onchange 属性时,页面会回发.添加 onchange 属性时不会.我是否仍然需要连接事件处理程序(我使用的是 C# .Net 2.0).

When I remove the onchange attribute from the DropdownList tag, the page does postback. It does not when the onchange attribute is added. Do I still need to wire the event handler (I'm on C# .Net 2.0 ).

任何线索都会有所帮助.

Any leads will be helpful.

谢谢!

推荐答案

您是否尝试过将 onChange 事件设置为 javascript 函数,然后在函数内部显示 javascript 警报并在通过时使用 __doPostback 函数?

Have you tried to set the onChange event to a javascript function and then inside the function display the javascript alert and utilize the __doPostback function if it passes?

   
drpControl.Attributes("onChange") = "DisplayConfirmation();"

function DisplayConfirmation() {
  if (confirm('Are you sure you want to do this?')) {
    __doPostback('drpControl','');
  }
}

这篇关于客户端确认后的下拉列表自动回传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆