2011-07-01 21 views
1

web表单我有一个正常的下拉列表:停止的DropDownList在Asp.net从清凉的

<asp:DropDownList ID="kindofser" runat="server" AutoPostBack="True" 
     Height="21px" Width="166px" 
     onselectedindexchanged="kindofser_SelectedIndexChanged"> 
     <asp:ListItem>שרתי משחק</asp:ListItem> 
     <asp:ListItem Value="1">rgrgr</asp:ListItem> 
     <asp:ListItem Value="2">rgreger</asp:ListItem> 

    </asp:DropDownList> 

每次我改变我的选择,一个SelectedIndexChanged事件发生,但页面刷新。我能阻止它发生吗?

回答

2

忽略从标记的AutoPostBack财产。

AutoPostBack获取或设置一个值,该值指示在DropDownList中所选索引已更改时是否发生自动回发到服务器。此DropDownList.AutoPostBack的默认值是false

如果你需要更新你的页面的数据的一部分,你可以使用Partial Page Updates with ASP.NET AJAX

+0

如果你把汽车后回假,当你改变你的选择它不是在做“保护无效XX_SelectedIndexChanged(对象发件人,EventArgs的){ ,所以,什么卡尼做 –

+0

@Alon?M:该事件将被解雇时页面被回传到服务器...... –

+0

事件不happnd ..如果我把“自动回”它没有做任何事情。只是没有..当将它happnd? –

1

AutoPostBack="False",而不是真实的。

+0

看看我西亚德在那里,如果你能回答..谢谢! –

1

SOLUTION:

在你的情况,你需要,因为您正在使用 “onselectedindexchanged” 事件使用的UpdatePanel。所以这里的代码

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
<ContentTemplate> 

<asp:DropDownList ID="kindofser" runat="server" AutoPostBack="True" 
     Height="21px" Width="166px" 
     onselectedindexchanged="kindofser_SelectedIndexChanged"> 
     <asp:ListItem>שרתי משחק</asp:ListItem> 
     <asp:ListItem Value="1">rgrgr</asp:ListItem> 
     <asp:ListItem Value="2">rgreger</asp:ListItem> 
</asp:DropDownList> 


</ContentTemplate> 
</asp:UpdatePanel> 

问候
阿里穆罕默德