C# asp:my usercontrol中的dropdownlist不会在SelectedIndexChanged上回发
我无法让usercontrol中的asp:下拉列表回发以更新天数 用户控件:C# asp:my usercontrol中的dropdownlist不会在SelectedIndexChanged上回发,c#,asp.net,user-controls,updatepanel,postback,C#,Asp.net,User Controls,Updatepanel,Postback,我无法让usercontrol中的asp:下拉列表回发以更新天数 用户控件: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Profile.ascx.cs" Inherits="TestApp2.Views.Profile" %> <asp:UpdatePanel ID="ProfileMainUpdatePanel" runat="server"> <ContentTe
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Profile.ascx.cs" Inherits="TestApp2.Views.Profile" %>
<asp:UpdatePanel ID="ProfileMainUpdatePanel" runat="server">
<ContentTemplate>
<div class="form-group profile-form">
<asp:DropDownList runat="server" id="selYear" class="form-control profile-date right-align" OnSelectedIndexChanged="selYear_SelectedIndexChanged" />
<asp:DropDownList runat="server" id="selMonth" class="form-control profile-date right-align" OnSelectedIndexChanged="selMonth_SelectedIndexChanged" />
<asp:DropDownList runat="server" id="selDay" class="form-control profile-date right-align"/>
<asp:label runat="server" class="control-label right-align profile-form-label" for="selDay" Text="Date of Birth" ID="temp" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
客户端代码为:
<script type="text/javascript">
function fillDays() {
alert("yes");
}
函数fillDays(){
警惕(“是”);
}
那也不会开火 您需要设置
AutoPostBack=“true”
以获取SelectedIndexChanged事件,默认值为false
<asp:DropDownList runat="server" id="selYear" AutoPostBack="true" class="form-control profile-date right-align" OnSelectedIndexChanged="selYear_SelectedIndexChanged" />
在更新面板中尝试此操作。希望它能工作。。。
我可以发誓我已经试过了。。。啊,我还保留了attribute.add,一旦我删除了它,它就可以与自动回邮一起工作了。但在将它插入到我的real usercontrol中之后,它要么不起作用,要么出于某种原因还克隆了月份和年份数字。我已经检查过,page_load没有再次启动,因此调用是部分刷新,填充月份和日期的方法也没有在初始加载后重新启动(应该是这样的),但是每年和每月的DropDownList在每次调用selectionchanged事件时都会被克隆。
<script type="text/javascript">
function fillDays() {
alert("yes");
}
<asp:DropDownList runat="server" id="selYear" AutoPostBack="true" class="form-control profile-date right-align" OnSelectedIndexChanged="selYear_SelectedIndexChanged" />
try this in Update Panel. Hope its working...
<asp:UpdatePanel ID="ProfileMainUpdatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<div class="form-group profile-form">
<asp:DropDownList runat="server" id="selYear" class="form-control profile-date right-align" OnSelectedIndexChanged="selYear_SelectedIndexChanged" />
<asp:DropDownList runat="server" id="selMonth" class="form-control profile-date right-align" OnSelectedIndexChanged="selMonth_SelectedIndexChanged" />
<asp:DropDownList runat="server" id="selDay" class="form-control profile-date right-align"/>
<asp:label runat="server" class="control-label right-align profile-form-label" for="selDay" Text="Date of Birth" ID="temp" />
</div>
</ContentTemplate>