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

我有一个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.启用相同或您可以比较上面建议的所选项目的索引.

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....