简体   繁体   English

DropDownList OnSelectedIndexChanged不会触发

[英]DropDownList OnSelectedIndexChanged does not fire

I have MVC4 Web application and i am rendering a partial view(.ascx) inside a .cshtml page. 我有MVC4 Web应用程序,并且正在.cshtml页面中渲染部分视图(.ascx)。 I have added a dropdownlist which has OnSelectedIndexChanged and it never fires. 我添加了一个具有OnSelectedIndexChanged的dropdownlist,它从不触发。 please see the code below 请参见下面的代码

Dashboard.ascx 仪表板.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Dashboard.ascx.cs" Inherits="iSPYCMS.Views.Dashboard" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
<title>Charts Example</title>  
</head>  
<body style="padding:50px;background-color:white">         

<form id="form1" runat="server">  

    <asp:DropDownList runat="server" ID="cmbTypeSeletion" Height="16px" Width="190px" EnableViewState="true" Enabled="true" OnSelectedIndexChanged="cmbTypeSeletion_SelectedIndexChanged">
        <asp:ListItem Enabled="true" Text="Downloads" Value="Downloads"> </asp:ListItem>
        <asp:ListItem Enabled="true" Text="Plays" Value="Plays"></asp:ListItem>
        <asp:ListItem Enabled="true" Text="Completion" Value="Completion"></asp:ListItem>
    </asp:DropDownList>
<div>  
    <script type="text/javascript" src="https://www.google.com/jsapi"> </script>  
    <asp:Literal ID="ltScripts" runat="server"></asp:Literal>  
    <div id="chart_div">  
    </div>  
</div>  
</form>  
</body>  
</html>  

Dashboard.ascx.cs Dashboard.ascx.cs

namespace iSPYCMS.Views
{
  public partial class Dashboard : ViewUserControl
  {
    protected void cmbTypeSeletion_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
  }
}

Index.cshtml Index.cshtml

@{
Layout = "~/Views/Shared/_Layout.cshtml";
}

<div>
 @Html.Partial("~/Views/Dashboard.ascx")
</div>

为下拉列表设置AutoPostBack =“ True”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM