Ben*_*Ben 3 c# asp.net updatepanel autopostback
当我更改所选项目时,我试图通过UpdatePanel将DropDownList获取到AutoPostBack.我有点激动,为什么这不起作用.
有没有人有任何快速的想法?
ASPX页面:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true" >
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>item 1</asp:ListItem>
<asp:ListItem>item 2</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
代码隐藏(我在字符串赋值上设置断点来捕获回发):
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string s = "";
}
Run Code Online (Sandbox Code Playgroud)
编辑:
好的,我现在就开始工作了.很奇怪.所需要的只是重新启动Visual Studio.作为一名开发人员,这种事情让我感到害怕;)我想我以前见过类似的东西,VS在运行的程序集中"不同步".
仅供参考我正在运行VS 2008 Web Developer Express.
感谢那些回答的人.
我能够让它与你发布的内容一起工作.这是我使用的代码...基本上你有什么,但我抛出异常.
<asp:ScriptManager ID="smMain" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true" >
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>item 1</asp:ListItem>
<asp:ListItem>item 2</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
throw new NotImplementedException();
}
Run Code Online (Sandbox Code Playgroud)
我尝试了很多变化,看看是否有什么关闭,但每次抛出异常.
您可能希望尝试异常路由以查看是否发生了回发,这不是调试器问题.
一个问题可能是Vista,而不是以管理员身份运行Visual Studios.我知道有一种不允许调试的倾向.
也许您运行的程序集与代码不匹配?如果您"在Browswer中查看"然后附加调试器,则可能会发生这种情况.
归档时间: |
|
查看次数: |
40912 次 |
最近记录: |