加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – 为什么在单击按钮时,SelectedIndexChanged会触发DropDow

发布时间:2020-12-16 04:10:15 所属栏目:asp.Net 来源:网络整理
导读:我有一个ASP.NET DropDownList,AutoPostBack = true,EnableViewState = false.我在页面上有一个什么都不做的按钮.如果我更改ddl中的选择,它会回发,这是预期的.如果我单击该按钮,页面会回发,并且会触发ddl的SelectedIndexChanged.为什么会被解雇? 解决方法
我有一个ASP.NET DropDownList,AutoPostBack = true,EnableViewState = false.我在页面上有一个什么都不做的按钮.如果我更改ddl中的选择,它会回发,这是预期的.如果我单击该按钮,页面会回发,并且会触发ddl的SelectedIndexChanged.为什么会被解雇?

解决方法

来自Microsoft的反馈: – http://connect.microsoft.com/VisualStudio/feedback/details/103844/dropdownlist-always-fire-selectedindexchanged-event-when-viewstate-is-disabled-and-the-selected-item-is-not-changed-by-the-user

“Thanks for your feedback. If
ViewState is disabled on the page or
on the DropDownList control,the
selected index cannot be saved,so
each postback looks like the selected
index has been changed. You can save
the selected index yourself and
compare against it to see if the
selection has really changed,or you
can enable ViewState on the
DropDownList. “

在您的情况下,下拉列表的视图状态为false.启用相同或您可以比较上面建议的所选项目的索引.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读