asp.net内容页面有CascadingDropDown的问题

时间:2010-03-16 18:58:21

标签: asp.net-ajax

我有一个带有更新面板的asp.net内容页面,带有ajax扩展器的asp.net控件,它有一个带有事件点击的asp.net按钮。 一切正常,只有一个案例。 我有3个带有CascadingDropDown扩展器的DropDownList。当我点击按钮而没有从DropDownLists中选择任何内容然后点击按钮时,事件点击将正常工作但是如果我选择任何内容,当我点击按钮时我的页面会响应。

我已经为点击按钮添加了触发器。

有什么我应该检查来解决这个问题???

这是我的代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="IMAM_APPLICATION.WebForm2" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
  <asp:UpdatePanel ID="UPDDL" runat="server">
     <ContentTemplate>
     <asp:Panel ID="PDDL" runat="server">
      <asp:DropDownList ID="cmbWorkField" runat="server" Style="top: 41px; left: 126px;
                    position: absolute; height: 22px; width: 126px">


                </asp:DropDownList>

                <asp:DropDownList runat="server" ID="cmbOccupation" Style="top: 77px; left: 127px;
                    position: absolute; height: 22px; width: 77px">

                </asp:DropDownList>
                <asp:DropDownList ID="cmbSubOccup" runat="server"
                    style="position:absolute; top: 116px; left: 126px;">

                </asp:DropDownList>

                <cc1:CascadingDropDown ID="cmbWorkField_CascadingDropDown" runat="server"
                    TargetControlID="cmbWorkField"
                    Category="WorkField"  
                    LoadingText="Please Wait ..."
                    PromptText="Select Wor kField ..."
                    ServiceMethod="GetWorkField"
                    ServicePath="ServiceTags.asmx">
                </cc1:CascadingDropDown>

                <cc1:CascadingDropDown ID="cmbOccupation_CascadingDropDown" runat="server"

                    TargetControlID="cmbOccupation"
                     Category="Occup"
                    LoadingText="Please wait..."
                    PromptText="Select Occup ..."
                    ServiceMethod="GetOccup"
                    ServicePath="ServiceTags.asmx"
                    ParentControlID="cmbWorkField">
                </cc1:CascadingDropDown>
                <cc1:CascadingDropDown ID="cmbSubOccup_CascadingDropDown" runat="server"
                    Category="SubOccup"
                    Enabled="True"
                     LoadingText="Please Wait..."
                    ParentControlID="cmbOccupation"
                    PromptText="Select Sub Occup"
                    ServiceMethod="GetSubOccup"
                    ServicePath="ServiceTags.asmx"
                    TargetControlID="cmbSubOccup">
                </cc1:CascadingDropDown>
                </asp:Panel>
         <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
     </ContentTemplate>

      <Triggers>
          <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
      </Triggers>

     </asp:UpdatePanel>


</asp:Content>

........................

here is the code behind:

....................................................

protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "you click me";
        }

2 个答案:

答案 0 :(得分:0)

我能够解决问题。

我添加的是删除更新面板并为页面设置EnableEventValidation =“False”。

答案 1 :(得分:0)

您所看到的问题记录在Codeplex上。请参阅jlewicki关于其他两个不需要关闭EventValidation的可能解决方案的帖子。