ASP.NET的DropDownList的AutoPostBack不工作 - 我在想什么? [英] ASP.NET DropDownList AutoPostback Not Working - What Am I Missing?

查看:99
本文介绍了ASP.NET的DropDownList的AutoPostBack不工作 - 我在想什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图得到一个DropDownList时,所选的项目更改为通过一个UpdatePanel的AutoPostBack。我会有点煸疯狂,为什么这是行不通的。

I am attempting to get a DropDownList to AutoPostBack via an UpdatePanel when the selected item is changed. I'm going a little stir-crazy as to why this isn't working.

没有人有任何想法快捷?

Does anyone have any quick ideas?

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>

code-背后(我把一个断点字符串赋值捕捉回传):

Code-behind (I put a breakpoint on the string assignment to capture the postback):

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
  string s = "";
}

编辑:

确定,我现在的工作。很奇怪。时采取了Visual Studio中的重新启动。这是我害怕作为一个开发者之类的话。)我想我之前类似,其中VS获取不同步WRT它的运行组装见过

FYI我运行VS 2008 Web开发前preSS。

多亏了那些回答。

推荐答案

我能得到它与你贴什么样的工作。这是code我用......基本上你有,但是我抛出一个异常。

I was able to get it to work with what you posted. This is the code I used... Basically what you had but I am throwing an exception.

   <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();
    }

我尝试了很多的变化,看看是否有东西了,但异常被抛出每次。

I tried a lot of variations to see if there was something off, but the exception was thrown every time.

您可能想尝试异常的路线,看是否回发发生,这不是一个调试器的问题。

You might want to try the exception route to see if the postback is happening and this isn't a debugger issue.


  • 有一个问题可能是与Vista不运行视觉工作室以管理员身份。我知道,有一种倾向不允许调试。

  • One issue might be with Vista and not running Visual Studios as administrator. I know that has a tendency to not allow debugging.

也许你正在运行的不匹配,code组装?这可能发生,如果你看Browswer,然后安装调试器。

Maybe the assembly you are running doesn't match the code? This might happen if you "View in Browswer" and then attach the debugger.

这篇关于ASP.NET的DropDownList的AutoPostBack不工作 - 我在想什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆