扩展程序不能与其扩展的控件位于不同的UpdatePanel中 [英] An extender can't be in a different UpdatePanel than the control it extends

查看:47
本文介绍了扩展程序不能与其扩展的控件位于不同的UpdatePanel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page  Title="CONTI TRAVELS" Language="VB" EnableEventValidation="false" MasterPageFile="~/Menu.master" AutoEventWireup="false" CodeFile="CreditInvoicePayment.aspx.vb" Inherits="CreditInvoicePayment" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="ContentCreditInvoicePayment" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="frmCreditInvoicePayment" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="SCMCreditPayment" EnablePartialRendering="true" runat="server" />
<script language="javascript" type="text/javascript">

    function printDiv(divID) {
        //Get the HTML of div
        var divElements = document.getElementById(divID).innerHTML;
        //Get the HTML of whole page
        var oldPage = document.body.innerHTML;

        //Reset the page's HTML with div's HTML only
        document.body.innerHTML =
              "<html><head><title></title></head><body>" +
              divElements + "</body>";

        //Print Page
        window.print();

        //Restore orignal HTML
        document.body.innerHTML = oldPage;

    }
    function enableOrdisableControls() {
        if (document.getElementById('<%=ddlPaymentFor.ClientID %>').value==1) {
            document.getElementById('<%=txtBillNo.ClientID %>').disabled = false;

            document.getElementById('<%=btnShowParticularBill.ClientID %>').disabled = false;
            document.getElementById('<%=ddlCustomerName.ClientID %>').disabled = true;
            document.getElementById('<%=btnShowFlexibleBill.ClientID %>').disabled = true;
            //document.getElementById('<%=lblBillReport.ClientID %>').innerHTML = "";

            setDropDownList(document.getElementById('<%=ddlCustomerName.ClientID %>'), '- Select -');
        } else if (document.getElementById('<%=ddlPaymentFor.ClientID %>').value==2) {
            document.getElementById('<%=txtBillNo.ClientID %>').disabled = true;
           // document.getElementById('<%=lblBillReport.ClientID %>').innerHTML = "";

            document.getElementById('<%=btnShowParticularBill.ClientID %>').disabled = true;
            document.getElementById('<%=ddlCustomerName.ClientID %>').disabled = false;
            document.getElementById('<%=btnShowFlexibleBill.ClientID %>').disabled = false;
            setDropDownList(document.getElementById('<%=ddlCustomerName.ClientID %>'), '- Select -');
        }

    }
    function ValidateParticularBill() {
        if (document.getElementById('<%=txtBillNo.ClientID %>').value == "") {
            alert("Enter Bill No");
            return false;
        } else {
        return true;
        }
    }
    function ValidateFlexibleBill() {
        if (document.getElementById('<%=ddlCustomerName.ClientID %>').value == "") {
            alert("Select Customer Name");
            return false;
        } else {
        return true;
        }
    }

    </script>
<table width="100%">
    <tr>
        <td align="right">
            <asp:Label ID="lblUserName" runat="server" CssClass="textBox" />
        </td>
    </tr>
</table>
<br />
<br />
<table >
    <tr>
        <td align="left" rowspan="2">
            <asp:Label ID="lblPaymentFor" Text="Payment For*" runat="server" CssClass="label" />
        </td>
        <td  align="left" rowspan="2">
         <asp:DropDownList ID="ddlPaymentFor" AutoPostBack="true" OnSelectedIndexChanged="ddlPaymentFor_SelectedIndexChanged" runat="server" CssClass="textbox" Width="160px"  />
         </td>
         <td  align="left">
             <asp:Label ID="lblBillNo" Text="Bill No:*" runat="server" CssClass="label" />
         </td>
         <td  align="left">
            <asp:TextBox ID="txtBillNo" runat="server" CssClass="textbox" Width="160px" />
         </td>
         <td align="left">
             <asp:Button ID="btnShowParticularBill" runat="server" CssClass="button" Text="Show Particular Bill" Width="160px" OnClientClick="return ValidateParticularBill();" />
         </td>
         </tr>
         <tr>
         <td align="left">
             <asp:Label ID="lblCustomerName" Text="Customer Name:*" runat="server" CssClass="label" />
         </td>
         <td align="left">
            <asp:DropDownList ID="ddlCustomerName" runat="server" CssClass="textBox" Width="160px" />
         </td>
         <td align="left">
            <asp:Button ID="btnShowFlexibleBill" runat="server" CssClass="button" Text="Show Customer Bill"  Width="160px" OnClientClick="return ValidateFlexibleBill();"/>
         </td>

       </tr>
       <tr>
         <td colspan="5">
         <asp:UpdatePanel ID="upBillDetails" runat="server" UpdateMode="Conditional" >
         <ContentTemplate>

           <div align="right">
             <asp:Button ID="btnPrint" Visible="false" runat="server" Text="Print" Width="120px" CssClass="button" OnClientClick="javascript:printDiv('pnlBill')" />
         </div>
         <asp:Panel ID="pnlBill" runat="server" Height="500px" ScrollBars="Auto">
         <asp:Label ID="lblBillReport" runat="server" CssClass="label" />
         </asp:Panel>
         <div>
            <div align="left">
                <asp:LinkButton ID="lbtnPaymentDetails" runat="server"  Text="Click Here to View Payment Details" />
            </div>
            <div align="center">
                <asp:Button ID="btnPaymentDetails" runat="server" CssClass="button" Text="Click To Enter Payment Details" Width="160px" />
            </div>
         </div>
         </ContentTemplate>
         <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddlPaymentFor" EventName="SelectedIndexChanged" />
         </Triggers>
         </asp:UpdatePanel>
         </td>
      </tr>
  </table>

      <msw:Border ID="pnlCreditPayment" CssClass="modalPopupBorder" runat="server" Width="700px" style="display:none;" ScrollBars="Auto" Title="Add Parcel">
      <table>
      <tr>
      <td  align="left">
        <asp:Label ID="lblPaidAmount" runat="server" Text="Paid Amount:*" CssClass="label" />
       </td>
       <td  align="left">
        <asp:TextBox ID="txtPaidAmount" runat="server" CssClass="textBox" Width="160px" />
       </td>
       </tr>
       <tr>
       <td  align="left">
         <asp:Label ID="lblPaymentType" runat="server" Text="Payment Type:" CssClass="label" />
       </td>
       <td  align="left">
          <asp:DropDownList ID="ddlPaymentType" runat="server" CssClass="textbox" Width="160px" />
       </td>
      </tr>
      <tr>
      <td  align="left">
            <asp:Label ID="lblTransactionId" runat="server" Text="Transaction Id:" CssClass="label" />
      </td>
      <td align="left">
            <asp:TextBox ID="txtTransactionId" runat="server" CssClass="textBox" Width="160px" />
      </td>
      </tr>
      <tr>
      <td align="center">
            <asp:Button ID="btnPaid" runat="server" CssClass="button" Text="Paid" Width="160px" />
      &nbsp;&nbsp;
            <asp:Button ID="btnCanel" runat="server" CssClass="button" Text="Cancel" Width="160px" />
      </td>
      </tr>

        </table>
        </msw:Border>

   <ajaxToolkit:ModalPopupExtender runat="server" ID="ModalPopupExtenderFreightType" TargetControlID="btnPaymentDetails" PopupControlID="pnlCreditPayment" DropShadow="true" BackgroundCssClass="modalBackground"  />

<!-- Popup for Error Message -->
    <asp:LinkButton ID="lnkErrorMessage" runat="server" />
       <asp:Panel ID="pnlErrorMessage" CssClass="modalPopup" runat="server" Width="500px" style="display:none;" >
        <table>
            <tr>
                <td class="popuppaneltitle" align="center">
                    <asp:Label runat="server" ID="lblErrorMessageHeader" Text="Error" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label runat="server" ID="lblErrorMessage" Text="" />
                </td>
            </tr>
            <tr>
                <td>
                    <div class="button_bar">
                        <asp:Button ID="btnErrorMessageOk" runat="server" CausesValidation="false" Text="Ok" Width="75px" CssClass="button" />
                    </div>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupErrorMessage" TargetControlID="lnkErrorMessage" PopupControlID="pnlErrorMessage" DropShadow="true" BackgroundCssClass="modalBackground" />
    </form>

</asp:Content>





Code Behind



Code Behind

 Protected Sub ddlPaymentFor_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPaymentFor.SelectedIndexChanged
        Try
            upBillDetails.Update()
            lblBillReport.Text = ""
            lbtnPaymentDetails.Visible = False
            btnPrint.Visible = False
            btnPaymentDetails.Visible = False

        Catch ex As Exception
            DisplayErrorMessage("ddlPaymentFor_SelectedIndexChanged", ex.Message + "\n" + ex.StackTrace)
        End Try
    End Sub

#End Region

推荐答案

Register Selecte dIndexChanged event for the DropDownList.



Instead of

Register SelectedIndexChanged event for the DropDownList.

Instead of
<asp:dropdownlist id="ddlPaymentFor" autopostback="true" runat="server" cssclass="textbox" width="160px" xmlns:asp="#unknown" />



write


write

<asp:dropdownlist id="ddlPaymentFor" autopostback="true" runat="server" onselectedindexchanged="ddlPaymentFor_SelectedIndexChanged" cssclass="textbox" width="160px" xmlns:asp="#unknown" />



Write the functionality in code behind:




Write the functionality in code behind:

protected void ddlPaymentFor_SelectedIndexChanged(Object sender, EventArgs e) 
{
//your code here
}


I had Placed the Modal Popup extender outside the update panel.Which thrown the error.

On replacing the modal popup extender inside the update panel will solve the error.
I had Placed the Modal Popup extender outside the update panel.Which thrown the error.
On replacing the modal popup extender inside the update panel will solve the error.


这篇关于扩展程序不能与其扩展的控件位于不同的UpdatePanel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆