DropDown事件不会触发 [英] DropDown Event won't fire

查看:155
本文介绍了DropDown事件不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个DropDownList,其功能是根据所选的分数改变颜色。以下是代码:



Hi,

I have a DropDownList who's function is to change its color depending on the scores selected. here are the codes:

<asp:DropDownList AutoPostBack="true" ID="rating1"  runat="server" Width="60px"

                      onselectedindexchanged="rating1_SelectedIndexChanged">
                      <asp:ListItem>NA</asp:ListItem>
                      <asp:ListItem>1</asp:ListItem>
                      <asp:ListItem>1.5</asp:ListItem>
                      <asp:ListItem>2</asp:ListItem>
                      <asp:ListItem>2.5</asp:ListItem>
                      <asp:ListItem>3</asp:ListItem>
                      <asp:ListItem>3.5</asp:ListItem>
                      <asp:ListItem>4</asp:ListItem>
                      <asp:ListItem>4.5</asp:ListItem>
                      <asp:ListItem>5</asp:ListItem>
                  </asp:DropDownList>







活动:






event:

protected void rating1_SelectedIndexChanged(object sender, EventArgs e)
  {
      float value = float.Parse(rating1.Text);
      if (value <= 3)
      {
          rating1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFF66");
      }
      else
      {
          rating1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FF3300");
      }
  }





从下拉列表中选择分数后,这个事件如何触发?



how can this event fire after selecting the scores from dropdown list??

推荐答案

在Google Chrome和IE中试用您的代码而不更改您发布的代码。两者似乎都有效。但在IE中,断点并没有出于某种原因。一旦我尝试为下拉列表添加EnableViewState为true,它就开始达到断点。您是否可以尝试相同。如果您仍然面临问题,请恢复。
Tried your Code in Google chrome and IE without any change in your posted code. Both seems to be working. But in IE , the Breakpoint was not hitting for some reason . Once I tried adding the EnableViewState to true for the dropdownlist , it started to hit the break point. Can you try the same .Please revert if your still facing the issue.


为什么不尝试rating1.SelectedItem.Value而不是rating1.Text
Why no you are trying rating1.SelectedItem.Value instead of rating1.Text


这篇关于DropDown事件不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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