2012-07-09 76 views
0

我一直有模態彈出窗口這個奇怪的問題。出於某種原因,當我選擇一個下拉項目時,我的更新按鈕不會觸發點擊事件。但隨後我將下拉列表的默認值更新爲更新按鈕。當選擇下拉菜單時,Modalpopup不會關閉

,這裏是我的aspx頁面代碼

<asp:Button ID="Button1" CssClass="hide" runat="server" Text="Button" /> 

<ajaxToolkit:ModalPopupExtender runat="server" ID="cfPopUp" PopupControlID="Panel4" 
    TargetControlID="Button1" OkControlID="cfUpdateBtn" CancelControlID="cfCancelBtn" /> 
<asp:Panel ID="Panel4" runat="server" CssClass="modalPopup"> 
    <asp:UpdatePanel ID="UpdatePanel2" runat="Server"> 
     <ContentTemplate> 
      <asp:Panel ID="Panel13" CssClass="" runat="server"> 
       <asp:Panel ID="Panel14" CssClass="" runat="server"> 
        <div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;"> 
         <asp:Label ID="Label25" Width="200px" runat="server" Text="Health and Safety Net" /><div 
          class="seperator"> 
         </div> 
         <table class="style143"> 
          <tr> 
           <td class="style185"> 
            <asp:Label ID="cfCategorylbl" runat="server" Text="Category:"></asp:Label>: 
           </td> 
           <td> 
            <asp:DropDownList ID="cbFactors_Categories" runat="server" Width="350px" Font-Names="Tahoma" 
             Font-Size="Small" ForeColor="DimGray" Height="24px" CssClass="style75"> 
            </asp:DropDownList> 
            <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="cbFactors_Categories" 
             Category="categories" ServiceMethod="getCategory" ServicePath="~/2012/IrSubmitWebService.asmx" 
             PromptText="Select Category" /> 
           </td> 
           <td align="center" rowspan="3" valign="top"> 
            <asp:Label ID="lblFactor_ID" runat="server" Font-Names="Tahoma" Font-Size="Small" 
             ForeColor="DimGray" Style="font-style: italic" TabIndex="56"></asp:Label> 
            <cc1:DynamicPopulateExtender ID="lblFactor_ID_DynamicPopulateExtender" runat="server" 
             Enabled="True" TargetControlID="lblFactor_ID" BehaviorID="dp1" ServiceMethod="getFactorID" 
             ServicePath="~/2012/IrSubmitWebService.asmx"> 
            </cc1:DynamicPopulateExtender> 
            <hr class="style157" /> 
            <asp:Label ID="cfID" runat="server" Font-Names="Tahoma" Font-Size="Small" ForeColor="DimGray" 
             Style="font-style: italic" Width="400px" TabIndex="57"></asp:Label> 
           </td> 
          </tr> 
          <tr> 
           <td class="style185"> 
            <asp:Label ID="cfTypeslbl" runat="server" Text="Type:"></asp:Label> 
           </td> 
           <td> 
            <asp:DropDownList ID="cbFactors_Types" runat="server" ForeColor="DimGray" Height="24px" 
             TabIndex="54" Width="350px" Font-Names="Tahoma" Font-Size="Small" CssClass="style75"> 
            </asp:DropDownList> 
            <cc1:CascadingDropDown ID="cbFactors_Types_CascadingDropDown" runat="server" 
             TargetControlID="cbFactors_Types" ParentControlID="cbFactors_Categories" Category="type" 
             ServiceMethod="getTypeofAction" ServicePath="~/2012/IrSubmitWebService.asmx" 
             PromptText="Select Type"> 
            </cc1:CascadingDropDown> 
           </td> 
          </tr> 
          <tr> 
           <td class="style185"> 
            <asp:Label ID="cfFactorslbl" runat="server" Text="Factor:"></asp:Label> 
           </td> 
           <td> 
            <asp:DropDownList ID="cbFactors_Factors" runat="server" ForeColor="DimGray" Height="24px" 
             TabIndex="55" Width="350px" Font-Names="tahoma" Font-Size="Small" CssClass="style75"> 
            </asp:DropDownList> 
            <cc1:CascadingDropDown ID="cbFactors_Factors_CascadingDropDown" runat="server" 
             TargetControlID="cbFactors_Factors" ParentControlID="cbFactors_Types" Category="category" 
             ServiceMethod="getFactor" ServicePath="~/2012/IrSubmitWebService.asmx" PromptText="Select Factor"> 
            </cc1:CascadingDropDown> 
           </td> 
          </tr> 
          <tr> 
           <td class="style185"> 
            <asp:Label Text="Justification:" ID="cfJustificationlbl" runat="server"></asp:Label> 
           </td> 
           <td colspan="2"> 
            <asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="29px" 
             Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine" 
             ToolTip="Provide a justification for this factor." Width="775px" Font-Names="Tahoma" 
             Font-Size="Small"></asp:TextBox> 
            </td> 
          </tr> 
         </table> 
         <br /> 
         <div style="text-align: center"> 
          <asp:Button CausesValidation="false" ID="cfUpdateBtn" runat="server" 
           Text="Update" CssClass="button" /><span style="margin-left: 10px"><asp:Button CausesValidation="false" 
            ID="cfCancelBtn" runat="server" Text="Cancel" CssClass="button" /></span></div> 
        </div> 
       </asp:Panel> 
      </asp:Panel> 
     </ContentTemplate> 
    </asp:UpdatePanel> 
</asp:Panel> 

和我的身後爲我更新的代碼(它只是關閉彈出)

Protected Sub cfUpdateBtn_Click(sender As Object, e As EventArgs) Handles cfUpdateBtn.Click 
    cfPopUp.Hide() 
End Sub 

對我的生活中,我想不通爲什麼當下拉菜單不是默認值時,更新按鈕將不起作用。

感謝您的幫助球員

+0

你是否運行你的代碼而不使用ajax級聯dropdownlist可能是工作 – 2012-07-09 16:03:38

+0

我不認爲它是級聯下拉列表,我有其他模式彈出窗口級聯下拉,它完美的作品。感謝您看我的問題。 – 2012-07-09 17:40:32

+0

好的,再嘗試一件事,你將你的下拉菜單與Web服務綁定在一起。如果您手動添加項目(意味着硬編碼)到您的下拉菜單仍不起作用? – 2012-07-09 17:49:29

回答

0

我基本上重建我的模式彈出並更新面板,像這樣

<asp:Panel ID="pnlEditPopup" runat="server" CssClass="modalPopup"> 
    <asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
    <ContentTemplate> 

     <asp:Panel ID="pnlEditPopupContent" runat="server"> 
      <div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;"> 
      <table cellpadding="0" cellspacing="4" border="0"> 
      <tr> 
       <td class="name">Category:</td> 
       <td class="value"> 
        <asp:DropDownList id="ddCat" runat="server"> 
         <asp:listitem value="">No Selection</asp:listitem> 
         <asp:listitem value="Action">Action</asp:listitem> 
         <asp:listitem value="Worksite">Worksite</asp:listitem> 
         <asp:listitem value="Human Factors">Human Factors</asp:listitem> 
         <asp:listitem value="System Factors">System Factors</asp:listitem> 
        </asp:DropDownList> 
       </td> 
      </tr> 
      <tr> 
       <td class="name">Type:</td> 
       <td class="value"> 
        <asp:DropDownList id="ddType" runat="server" /> 
        <ajaxToolkit:CascadingDropDown ID="ccType" runat="server" 
         TargetControlID="ddType" 
         ParentControlID="ddCat" 
         PromptText="No Selection" 
         LoadingText="Please Wait..." 
         ServicePath="~/2012/IrSubmitWebService.asmx" 
         ServiceMethod="getTypeofAction" 
         Category="Other" 
        /> 
       </td> 
      </tr> 
      <tr> 
       <td class="name">Factor:</td> 
       <td class="value"> 
        <asp:DropDownList id="ddfactor" runat="server" /> 
        <ajaxToolkit:CascadingDropDown ID="ccFactor" runat="server" 
         TargetControlID="ddfactor" 
         ParentControlID="ddType" 
         PromptText="No Selection" 
         LoadingText="Please Wait..." 
         ServicePath="~/2012/IrSubmitWebService.asmx" 
         ServiceMethod="getFactor" 
         Category="Other" 
        /> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        Justification: 
        <asp:Label ID="factorID" runat="server" Visible="false"></asp:Label> 
       </td> 

       <td> 
        <asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="100px" 
        Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine" 
        ToolTip="Provide a justification for this factor." Width="300px" Font-Names="Tahoma" 
        Font-Size="Small"></asp:TextBox> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        Factor ID<br /> 
        and Description:    
       </td> 
       <td> 
        <asp:Label ID="factor_id_Desc" runat="server" Width="300px" Font-Names="Tahoma" Font-Size="Small" 
         ForeColor="DimGray" TabIndex="56"></asp:Label> 
        <cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server" 
         Enabled="True" TargetControlID="factor_id_Desc" BehaviorID="dp1" ServiceMethod="getFactorID" 
         ServicePath="~/2012/IrSubmitWebService.asmx"> 
        </cc1:DynamicPopulateExtender> 
       </td> 
      </tr> 
      <tr> 
       <td colspan="2" align="center"> 
        <asp:Button ID="btnOkEditPopup" runat="server" Text="Ok" CssClass="button"/> 
        <span style="margin-left:10px"><asp:button id="btnCancelEditPopup" runat="server" text="Cancel" CssClass="button"/></span> 
       </td> 
      </tr> 

      </table> 
      </div> 
     </asp:Panel> 

    </ContentTemplate> 
    </asp:UpdatePanel> 
    </asp:Panel> 

    <ajaxToolkit:ModalPopupExtender ID="mpeEdit" runat="server" 
     TargetControlID="btnOpenEditPopup" 
     PopupControlID="pnlEditPopup" 
     /> 

固定我的問題。當我問這個問題時,我仍然不知道爲什麼它不起作用,但我能解決這個問題。感謝所有爲我研究它的人。

0

可能的原因可能是您使用的是Web服務綁定您的下拉列表。每當你點擊下拉列表中的一個項目時,可能會調用webservice。如果webservice被調用,那麼可能是你的頁面再次加載?我不知道它不工作的確切原因。您必須檢查服務行爲在調用服務時發生了什麼。

+0

因爲它的ajax控件頁面不重新加載。 Web服務使其異步。我一直在網上搜索,這應該有可能完成。 – 2012-07-09 18:48:27

+0

好吧,如果你找到了解決方案,那麼也與我們分享,還有一件事是asp下拉列表與web服務一起工作,或者不檢查它。 – 2012-07-09 18:57:40