簡體   English   中英

如何防止一個更新面板影響另一個 c# asp

[英]How to prevent one update panel from affecting another c# asp

我的問題如下,當我第一次使用第一個更新面板的下拉列表正常運行時,它向我顯示隱藏的標簽和文本框,一切正常。

但是,當我首先使用 dropProvince、canton 或 District 時,它們實現了該方法

protected void 
droplistTipoIdentificacionDatosPropietario_SelectedIndexChanged (object sender, EventArgs and )
{
    MessageBox.Show ("hello");
    this.datosPropietarioLblNumIdentificacion.Visible = true;
    this.datosPropietariotxtNumIdentificacion.Visible = true;
}

每滴都有自己的方法

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {               
        this.datosPropietarioLblNumIdentificacion.Visible = false;
        this.datosPropietariotxtNumIdentificacion.Visible = false;
    }
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Label runat="server" Text="Tipo de Identificación"></asp:Label>
        <asp:DropDownList ID="droplistTipoIdentificacionDatosPropietario"
            runat="server" 
            Width="100%" 
            Height="30px"
            AutoPostBack="true" 
            OnSelectedIndexChanged="droplistTipoIdentificacionDatosPropietario_SelectedIndexChanged">
            <asp:ListItem Text="Cédula Identidad" Value="C"></asp:ListItem>
            <asp:ListItem Text="Cédula de Residencia" Value="R"></asp:ListItem>
            <asp:ListItem Text="Cédula Jurídica" Value="J"></asp:ListItem>
            <asp:ListItem Text="Pasaporte" Value="P"></asp:ListItem>
        </asp:DropDownList>
    </ContentTemplate>
</asp:UpdatePanel>

代碼隱藏調用

protected void droplistTipoIdentificacionDatosPropietario_SelectedIndexChanged(object sender, EventArgs e)
{
    MessageBox.Show("hola");
    this.datosPropietarioLblNumIdentificacion.Visible = true;
    this.datosPropietariotxtNumIdentificacion.Visible = true;
}
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="grid3">
            <asp:Label runat="server" Text="Provincia"></asp:Label>
            <asp:DropDownList ID="droplistProvincia" 
                AutoPostBack="true" onchange="testProvincia"
                OnSelectedIndexChanged="droplistProvincia_SelectedIndexChanged" 
                Width="100%" runat="server" Height="30px">
                <asp:ListItem Text="Seleccione"></asp:ListItem>
            </asp:DropDownList>
            <asp:Label runat="server" Text="Cantón"></asp:Label>
            <asp:DropDownList ID="droplistCanton" CssClass="item15" 
                AutoPostBack="true" 
                OnSelectedIndexChanged="droplistCanton_SelectedIndexChanged" 
                Width="100%" runat="server" Height="30px">
                <asp:ListItem Text="Seleccione"></asp:ListItem>
            </asp:DropDownList>
            <asp:Label runat="server" CssClass="item16" Text="Distrito"></asp:Label>
            <asp:DropDownList ID="droplistDistrito"
                AutoPostBack="true" 
                OnSelectedIndexChanged="droplistDistrito_SelectedIndexChanged" 
                CssClass="item17"  runat="server" Height="30px">
                <asp:ListItem Text="Seleccione"></asp:ListItem>
            </asp:DropDownList>
        </ContentTemplate>
    </asp:UpdatePanel>

您可能有復制/粘貼問題; 有時復制/粘貼不會執行代碼。 嘗試從每個下拉列表中刪除代碼隱藏方法並重新添加它們。

<asp:DropDownList ID="droplistProvincia" 
    AutoPostBack="true" onchange="testProvincia"
    OnSelectedIndexChanged="droplistProvincia_SelectedIndexChanged" <- delete this
    Width="100%" runat="server" Height="30px">
    <asp:ListItem Text="Seleccione"></asp:ListItem>
</asp:DropDownList>

刪除如上所示的行,並刪除代碼隱藏。 通過雙擊下拉列表重新添加。

希望有幫助。 很難從您的問題中判斷問題出在哪里。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM