onChange="Show(this.value)"                     <asp:DropDownList ID="ddlType" onChange="Show(this.value)" runat="server" CssClass="txt"
                        AutoPostBack="false">
                        <asp:ListItem Value="1">大专</asp:ListItem>
                        <asp:ListItem Value="2">本科</asp:ListItem>
                        <asp:ListItem Value="3">博士</asp:ListItem>
                    </asp:DropDownList>function Show(value) {
            alert(value);            if (value == "1") {
                document.getElementById("1").style.display = "block";
                document.getElementById("2").style.display = "none";
                document.getElementById("3").style.display = "none";
            }
            if (value == "2") {
                document.getElementById("1").style.display = "none";
                document.getElementById("2").style.display = "block";
                document.getElementById("3").style.display = "none";
            }
            if (value == "3") {
                document.getElementById("1").style.display = "none";
                document.getElementById("2").style.display = "none";
                document.getElementById("3").style.display = "block";
            }
        }后台if(!ispostback) ddlType.SelectedIndex =Object.value;   分不多了,麻烦大家帮我看看,谢谢

解决方案 »

  1.   

    AutoPostBack="false"你设置了这个
      

  2.   

    onChange="Show(this.value)" 事件单独可以,就是我想在动态绑定ddltype的selectindex值时,也想要触发这个事件,正确选择层显示隐藏
      

  3.   

    在下拉框后面拖一个Literal控件,后台改变selectindex后:
    Literal1.Text="<script>Show('"+"this.Value对应的值"+"')</script>";也就是后台改变后,显式调用一次Show方法。根据需要,可以禁用Literal1的viewstate
      

  4.   

    Page.ClientScript.RegisterStartupScript(this.GetType(), "show", "$(function(){show(1)});", true);
      

  5.   


    测试 ie ff chrome 没问题啊
      

  6.   

    少个分号!~
    Page.ClientScript.RegisterStartupScript(this.GetType(), "show", "$(function(){show(1);});", true);
      

  7.   


    ddlType.Attributes["onchange"] = "Show(this.value);";
      

  8.   


    ?能写具体点吗?拖到dropdownlist 后面?那怎么关联dropdownlist?
      

  9.   

    如果不设置这个的话,我每次onchange事件都会刷新整个页面