如何在asp.net中控制dropdownlist auotpostback?
我有一个带有自动回邮功能的下拉列表和一个更新面板,它工作正常, 但我的页面中还有其他带有autopostback的控件。 我需要的是控制页面何时为自动回邮,而dropdownlist何时不是自动回邮。请执行以下操作:如何在asp.net中控制dropdownlist auotpostback?,asp.net,vb.net,dropdown,ispostback,Asp.net,Vb.net,Dropdown,Ispostback,我有一个带有自动回邮功能的下拉列表和一个更新面板,它工作正常, 但我的页面中还有其他带有autopostback的控件。 我需要的是控制页面何时为自动回邮,而dropdownlist何时不是自动回邮。请执行以下操作: If is not Page.autopostback then 'do something else if is not MyDropdownlist.autopostback then ' do something different
If is not Page.autopostback then
'do something
else if is not MyDropdownlist.autopostback then
' do something different
End if
我可以用这个:
If is not Page.autopostback then
End If
但我不能这样做:
If is not MyDropdownlist.autopostback then
End If
那我该怎么做呢?我希望我的解释能有所帮助,谢谢。请求表单变量的名称是导致回发的控件。您可以查询此控件的名称并执行任何操作 比如说,
If IsPostBack Then
Dim postBackControlId As String = Request.Form("__EVENTTARGET")
If Not String.IsNullOrEmpty(postBackControlId) Then
If postBackControlId = "DropdownList1" Then
' the postback happened due to DropdownList1
Else
' the postback happened due to some other control.
End If
End If
End If
\uu EVENTTARGET
请求表单变量具有导致回发的控件名称。您可以查询此控件的名称并执行任何操作
比如说,
If IsPostBack Then
Dim postBackControlId As String = Request.Form("__EVENTTARGET")
If Not String.IsNullOrEmpty(postBackControlId) Then
If postBackControlId = "DropdownList1" Then
' the postback happened due to DropdownList1
Else
' the postback happened due to some other control.
End If
End If
End If
你能详细解释一下你想要实现的目标吗?很抱歉我解释错了,我想做一些代码,但只有当页面是自动回邮但dropdownlist不是自动回邮时,你才可以使用page.IsPostback属性进行页面回邮并检查dropdown的选定值。不知道你为什么需要这样的东西。解释清楚的逻辑。你能详细解释一下你想要实现的目标吗?对不起,我解释错了,我想做一些代码,但只有当页面是自动回邮但dropdownlist不是自动回邮时,你才能使用page.IsPostback属性进行页面回邮并检查dropdown的选定值。不知道你为什么需要这样的东西。解释清楚的逻辑。非常感谢你的解释,它是正确的,这正是我要找的:-D非常感谢你的解释,它是正确的,这正是我要找的:-D