Ich habe MVC4 Web-Anwendung und ich Rendern eine Teilansicht (ASCX) innerhalb einer .Cshtml-Seite. Ich habe eine Dropdown-Liste hinzugefügt, die OnSelectedIndexChanged hat und nie ausgelöst wird. finden Sie den Code untenDropDownList OnSelectedIndexChanged feuert nicht
Dashboard.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
namespace iSPYCMS.Views
{
public partial class Dashboard : ViewUserControl
{
protected void cmbTypeSeletion_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
Index.cshtml
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div>
@Html.Partial("~/Views/Dashboard.ascx")
</div>
Sie mischen Webforms mit MVC .. nicht gut – giammin
Ja, ich weiß in der Tat, ich musste Google-Diagramm verwenden, und ich konnte kein gutes Beispiel für MVC dafür finden, also ich used user control –
google charts braucht keine webforms/postbacks überhaupt – giammin