locked
Unable to make show and hide for panels work inside updatepanel RRS feed

  • Question

  • User-718146471 posted

    Hey folks, I am trying my darnedest to make this work but it simply won't do it. I have my asp:Panel calls inside the updatepanel so I am only trying to hide those elements contained inside the panels. Here is my code:

    .aspx

    <%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ManageVulns.aspx.cs" Inherits="System.Contact" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
        <title>Manage Vulnerabilities</title>
           <style type="text/css">
               .cssPager td {
                   padding-left: 4px;
                   padding-right: 4px;
               }
               .auto-style2 {
                   text-align: center;
               }
            </style>
    </asp:Content>
    <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdateProgress AssociatedUpdatePanelID="upd_Listing" runat="server">
            <ProgressTemplate>
                <div style="; vertical-align:middle;">
                    <img src="Images/ajax-loader.gif" alt="Refreshing..." width="48" height="48" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <%-- Add UpdatePanel here and use DIV tag for Show/Hide --%>
            <h1 class="auto-style2">Manage Vulnerabilities </h1>
            <asp:LinkButton ID="lbAddVuln" runat="server" OnClick="lbAddVuln_Click">Add Vulnerability</asp:LinkButton>
            <br /><br />
        <asp:UpdatePanel runat="server" ID="upd_Listing" ChildrenAsTriggers="true" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel ID="pnlVulnList" runat="server" Visible="true">
        <asp:GridView ID="gv_VulnList" runat="server" AutoGenerateColumns="False" CellPadding="1" DataKeyNames="Id" 
            ForeColor="#333333" Width="100%" AllowPaging="True" OnPageIndexChanging="gv_VulnList_PageIndexChanging"
            HorizontalAlign="Left" CellSpacing="1" >
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:TemplateField ShowHeader="False" ItemStyle-Width="50px" ItemStyle-Wrap="false">
                    <ItemTemplate>
                        <asp:LinkButton ID="HyperLink3" runat="server" CausesValidation="False" CommandArgument='<%# Eval("Id") %>' OnClick="HyperLink3_Click"><img src="Images/edit_page.png" width="25px" height="25px" border="0" alt="Edit/View" /></asp:LinkButton>
                        <asp:LinkButton ID="HyperLink4" runat="server" CausesValidation="False" OnClientClick="if ( !confirm('Are you sure you want to delete this vulnerability?')) return false;" CommandArgument='<%# Eval("Id") %>' OnClick="HyperLink4_Click"><img src="Images/delete.jpg" width="25px" height="25px" alt="Delete" border="0" /></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name" SortExpression="Vuln_Name">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Vuln_Name") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="150px" Wrap="False" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Summary" SortExpression="Vuln_Short_Descr">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Vuln_Short_Descr") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="150px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Description" SortExpression="Vuln_Long_Descr" Visible="False">
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("Vuln_Long_Descr") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="200px" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="" SortExpression="Vuln_Reference" ItemStyle-HorizontalAlign="Right">
                    <ItemTemplate>
                        <asp:HyperLink ID="lnkReference" runat="server" NavigateUrl='<%# Bind("Vuln_Reference") %>' Target="_blank"><asp:Image runat="server" ImageUrl="~/images/www.png" Width="25px" Height="25px" BorderStyle="None" /></asp:HyperLink>
                    </ItemTemplate>
                    <ItemStyle Width="50px" HorizontalAlign="Center" VerticalAlign="Top" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Notes" SortExpression="Vuln_Notes" Visible="False">
                    <ItemTemplate>
                        <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Vuln_Notes") %>'></asp:HyperLink> 
                    </ItemTemplate>
                    <ItemStyle Width="250px" />
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" CssClass="cssPager" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" HorizontalAlign="Left" VerticalAlign="Top" Font-Size="Small" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView></asp:Panel>
                </ContentTemplate>
        </asp:UpdatePanel>
    
        <asp:UpdateProgress AssociatedUpdatePanelID="upd_AddVuln" runat="server">
            <ProgressTemplate>
                <div style="; vertical-align:middle;">
                    <img src="Images/ajax-loader.gif" alt="Refreshing..." width="48" height="48" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <%-- Add UpdatePanel here and use DIV tag for Show/Hide --%>
        <asp:UpdatePanel runat="server" ID="upd_AddVuln" ChildrenAsTriggers="true" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel ID="pnl_AddVuln" runat="server" Visible="false">
            <asp:DetailsView ID="dv_AddVuln" runat="server" Height="50px" Width="673px" AutoGenerateRows="False" DefaultMode="Insert" >
                <Fields>
                    <asp:TemplateField HeaderText="Name" SortExpression="Vuln_Name">
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Vuln_Name") %>' Width="640px"></asp:TextBox>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Summary" SortExpression="Vuln_Short_Descr">
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Vuln_Short_Descr") %>' Width="640px"></asp:TextBox>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Details" SortExpression="Vuln_Long_Descr">
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox3" runat="server" Rows="5" Text='<%# Bind("Vuln_Long_Descr") %>' TextMode="MultiLine" Width="640px"></asp:TextBox>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Reference" SortExpression="Vuln_Reference">
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Vuln_Reference") %>' Width="640px"></asp:TextBox>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Notes" SortExpression="Vuln_Notes">
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox5" runat="server" Rows="5" Text='<%# Bind("Vuln_Notes") %>' TextMode="MultiLine" Width="640px"></asp:TextBox>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <InsertItemTemplate>
                            <asp:LinkButton ID="lnkInsertVuln" Text="Insert" runat="server" OnClick="btnInsertVuln_Click"><img src="Images/insert.jpg" width="25px" height="25px" border="0" alt="Insert"/></asp:LinkButton>
                            <asp:LinkButton ID="lnkCancelIns" Text="Cancel" runat="server" OnClick="btnCancelIns_Click"><img src="Images/cancel.jpg" width="25px" height="25px" border="0" alt="Cancel" /></asp:LinkButton>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                </Fields>
                <InsertRowStyle Wrap="False" HorizontalAlign="Left" VerticalAlign="Top" />
            </asp:DetailsView>
                    </asp:Panel>
    </ContentTemplate>
            </asp:UpdatePanel>
    
            <asp:UpdateProgress AssociatedUpdatePanelID="upd_EditVuln" runat="server">
            <ProgressTemplate>
                <div style="; vertical-align:middle;">
                    <img src="Images/ajax-loader.gif" alt="Refreshing..." width="48" height="48" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="upd_EditVuln" runat="server">
            <ContentTemplate>
                <asp:Panel ID="pnlUpdate" runat="server" Visible="false">
            <asp:DetailsView ID="dv_UpdVuln" runat="server" 
                AutoGenerateRows="False" DefaultMode="Edit" Width="683px" DataKeyNames="Id" >
                <EditRowStyle VerticalAlign="Top" />
                <Fields>
                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
                    <asp:TemplateField HeaderText="Name" SortExpression="Vuln_Name">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Vuln_Name") %>' Width="100%"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Summary" SortExpression="Vuln_Short_Descr">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Vuln_Short_Descr") %>' Width="50%"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Details" SortExpression="Vuln_Long_Descr">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox3" runat="server" Rows="4" Text='<%# Bind("Vuln_Long_Descr") %>' TextMode="MultiLine" Width="100%"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Reference" SortExpression="Vuln_Reference">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Vuln_Reference") %>' Width="100%"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Notes" SortExpression="Vuln_Notes">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox5" runat="server" Rows="5" Text='<%# Bind("Vuln_Notes") %>' TextMode="MultiLine" Width="100%"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" OnClick="LinkButton1_Click" Text="Update" CommandArgument='<%# Eval("Id") %>'><img src="images/update.png" width="50px" height="50px" /></asp:LinkButton>
                            &nbsp;<asp:LinkButton ID="lnkUpdCancel" runat="server" CausesValidation="False" OnClick="LinkButton2_Click1" Text="Cancel"><img src="images/cancel.jpg" width="50px" height="50px" /></asp:LinkButton>
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
                    </asp:Panel>
                </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Content>

    aspx.cs

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WASAuditSystem
    {
        #region Initial Page Loading
        public partial class Contact : Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (Page.IsPostBack)
                {
                    FillGV();
                }
                if (!Page.IsPostBack)
                {
                    FillGV();
                }
            }
            #endregion
    
            #region Gridview and DetailViews
    
            protected void gv_VulnList_PageIndexChanging (object Sender, GridViewPageEventArgs e)
            {
                gv_VulnList.PageIndex = e.NewPageIndex;
                gv_VulnList.DataBind();
            }
            protected void lbAddVuln_Click(object sender, EventArgs e)
            {
                // AddVuln visible
                pnlVulnList.Visible = false;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = true;
            }
    
            protected void LinkButton1_Click1(object sender, EventArgs e)
            {
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
                //gv_VulnList visible
            }
    
            protected void LinkButton2_Click(object sender, EventArgs e)
            {
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
                //gv_VulnList visible
            }
    
            protected void LinkButton3_Click(object sender, EventArgs e)
            {
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
                //gv_VulnList visible
            }
    
            protected void LinkButton4_Click(object sender, EventArgs e)
            {
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
                //gv_VulnList visible
            }
    
            protected void btnInsertVuln_Click(object sender, EventArgs e)
            {
                InsertData();
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
    
                //gv_VulnList visible
            }
    
            protected void btnCancelIns_Click(object sender, EventArgs e)
            {
                //gv_VulnList visible
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
    
            }
    
            protected void HyperLink3_Click(object sender, EventArgs e)
            {
                LinkButton btn = (LinkButton)(sender);
                string RecID = btn.CommandArgument;
    
                string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                string SelQuery = "SELECT * FROM Vulnerabilities where Id = @Id ORDER BY Vuln_Name";
    
                SqlConnection conn = new SqlConnection(ConnStr);
                SqlCommand cmd = new SqlCommand(SelQuery, conn);
                cmd.Parameters.AddWithValue("Id", RecID);
    
                SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);
                DataTable sqlDt = new DataTable();
                sqlDa.Fill(sqlDt);
    
                dv_UpdVuln.DataSource = sqlDt;
                dv_UpdVuln.DataBind();
    
                // dv_Update Visible
                pnlVulnList.Visible = false;
                pnlUpdate.Visible = true;
                pnl_AddVuln.Visible = false;
    
            }
    
            protected void LinkButton2_Click1(object sender, EventArgs e)
            {
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
    
                //gv_VulnList visible
            }
    
            protected void LinkButton1_Click(object sender, EventArgs e)
            {
                LinkButton btn = (LinkButton)(sender);
                string RecID = btn.CommandArgument;
    
                UpdateData(Convert.ToInt32(RecID));
                pnlVulnList.Visible = true;
                pnlUpdate.Visible = false;
                pnl_AddVuln.Visible = false;
    
                //gv_VulnList visible
            }
    
            protected void HyperLink4_Click(object sender, EventArgs e)
            {
                LinkButton btn = (LinkButton)(sender);
                string RecID = btn.CommandArgument;
                DeleteData(Convert.ToInt32(RecID));
            }
            #endregion
    
            #region DataWorks
            protected void UpdateData(int id)
            {
                TextBox VulnName = ((TextBox)dv_UpdVuln.FindControl("TextBox1"));
                TextBox VulnShort = ((TextBox)dv_UpdVuln.FindControl("TextBox2"));
                TextBox VulnLong = ((TextBox)dv_UpdVuln.FindControl("TextBox3"));
                TextBox VulnRef = ((TextBox)dv_UpdVuln.FindControl("TextBox4"));
                TextBox VulnNotes = ((TextBox)dv_UpdVuln.FindControl("TextBox5"));
    
                string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                string UpdQuery = "UPDATE Vulnerabilities SET Vuln_Name = @Vuln_Name, Vuln_Short_Descr = @Vuln_Short_Descr, Vuln_Long_Descr = @Vuln_Long_Descr, Vuln_Reference = @Vuln_Reference, Vuln_Notes = @Vuln_Notes WHERE (Id = @Id)";
    
                SqlConnection conn = new SqlConnection(ConnStr);
                SqlCommand cmd = new SqlCommand(UpdQuery, conn);
    
                cmd.Parameters.AddWithValue("Id", id);
                cmd.Parameters.AddWithValue("Vuln_Name", VulnName.Text.ToString());
                cmd.Parameters.AddWithValue("Vuln_Short_Descr", VulnShort.Text.ToString());
                cmd.Parameters.AddWithValue("Vuln_Long_Descr", VulnLong.Text.ToString());
                cmd.Parameters.AddWithValue("Vuln_Reference", VulnRef.Text.ToString());
                cmd.Parameters.AddWithValue("Vuln_Notes", VulnNotes.Text.ToString());
    
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                FillGV();
            }
    
            protected void InsertData()
            {
                TextBox VulnName = ((TextBox)dv_AddVuln.FindControl("TextBox1"));
                TextBox VulnShort = ((TextBox)dv_AddVuln.FindControl("TextBox2"));
                TextBox VulnLong = ((TextBox)dv_AddVuln.FindControl("TextBox3"));
                TextBox VulnRef = ((TextBox)dv_AddVuln.FindControl("TextBox4"));
                TextBox VulnNotes = ((TextBox)dv_AddVuln.FindControl("TextBox5"));
    
    
                string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                string InsQuery = "INSERT INTO Vulnerabilities (Vuln_Name,Vuln_Short_Descr,Vuln_Long_Descr,Vuln_Reference,Vuln_Notes) values (@VulnName,@VulnShort,@VulnLong,@VulnRef,@VulnNotes)";
    
                SqlConnection conn = new SqlConnection(ConnStr);
                SqlCommand cmd = new SqlCommand(InsQuery, conn);
    
                cmd.Parameters.AddWithValue("VulnName", VulnName.Text.ToString());
                cmd.Parameters.AddWithValue("VulnShort", VulnShort.Text.ToString());
                cmd.Parameters.AddWithValue("VulnLong", VulnLong.Text.ToString());
                cmd.Parameters.AddWithValue("VulnRef", VulnRef.Text.ToString());
                cmd.Parameters.AddWithValue("VulnNotes", VulnNotes.Text.ToString());
    
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                FillGV();
            }
    
            protected void DeleteData(int id)
            {
                string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                string DelQuery = "DELETE FROM Vulnerabilities where Id = @Id";
    
                SqlConnection conn = new SqlConnection(ConnStr);
                SqlCommand cmd = new SqlCommand(DelQuery, conn);
                cmd.Parameters.AddWithValue("Id", id);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                FillGV();
            }
    
            protected void FillGV()
            {
                string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                string SelQuery = "SELECT * FROM Vulnerabilities ORDER BY Vuln_Name";
    
                SqlConnection conn = new SqlConnection(ConnStr);
                SqlCommand cmd = new SqlCommand(SelQuery, conn);
    
                SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);
                DataTable sqlDt = new DataTable();
                sqlDa.Fill(sqlDt);
    
                gv_VulnList.DataSource = sqlDt;
                gv_VulnList.DataBind();
            }
    
            protected void FillEditDV(object sender, EventArgs e)
            {
                LinkButton btn = (LinkButton)(sender);
                string RecID = btn.CommandArgument;
    
                string ConnStr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                string SelQuery = "SELECT * FROM Vulnerabilities where Id = @Id";
    
                SqlConnection conn = new SqlConnection(ConnStr);
                SqlCommand cmd = new SqlCommand(SelQuery, conn);
                cmd.Parameters.AddWithValue("Id", RecID);
    
                SqlDataAdapter sqlDa = new SqlDataAdapter(cmd);
                DataTable sqlDt = new DataTable();
                sqlDa.Fill(sqlDt);
    
                dv_UpdVuln.DataSource = sqlDt;
                dv_UpdVuln.DataBind();
            }
            #endregion
        }
    }

    Friday, August 26, 2016 10:52 AM

Answers

  • User61956409 posted

    Hi bbcompent1,

    It seems that you’d like to show/hide panels dynamically from code behind, so please debug the code to make sure if linkbutton click event could fire as expected.

    And the following sample code works fine on my side, I could hide the panel on linbutton click event, you could create a new web page to test the code.

    <asp:LinkButton ID="lbAddVuln" runat="server" OnClick="lbAddVuln_Click">Add Vulnerability</asp:LinkButton>
    
    <asp:UpdatePanel runat="server" ID="upd_Listing" ChildrenAsTriggers="true" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="pnlVulnList" runat="server" Visible="true">
                VulnList panel
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    
    protected void lbAddVuln_Click(object sender, EventArgs e)
    {
        pnlVulnList.Visible = false;
    }

    Besides, you could try to call Update method to update the content of an UpdatePanel control.

    https://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.update(v=vs.110).aspx

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 1, 2016 6:43 AM

All replies

  • User-351321909 posted

    Hi bbcompent1,

    You need to place your linkbutton inside the update panel for it to work.

    You can refer this link:

    http://stackoverflow.com/questions/2539204/panel-visible-true-has-no-effect

    Monday, August 29, 2016 12:03 PM
  • User-718146471 posted

    I'll certainly give it a try and let you know. Thanks :)

    Monday, August 29, 2016 8:25 PM
  • User61956409 posted

    Hi bbcompent1,

    It seems that you’d like to show/hide panels dynamically from code behind, so please debug the code to make sure if linkbutton click event could fire as expected.

    And the following sample code works fine on my side, I could hide the panel on linbutton click event, you could create a new web page to test the code.

    <asp:LinkButton ID="lbAddVuln" runat="server" OnClick="lbAddVuln_Click">Add Vulnerability</asp:LinkButton>
    
    <asp:UpdatePanel runat="server" ID="upd_Listing" ChildrenAsTriggers="true" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="pnlVulnList" runat="server" Visible="true">
                VulnList panel
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    
    protected void lbAddVuln_Click(object sender, EventArgs e)
    {
        pnlVulnList.Visible = false;
    }

    Besides, you could try to call Update method to update the content of an UpdatePanel control.

    https://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.update(v=vs.110).aspx

    Best Regards,

    Fei Han



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 1, 2016 6:43 AM
  • User-718146471 posted

    Ok, let me try this and get back to you. I did not forget, last week was a monster busy week for me.

    Monday, September 12, 2016 11:56 AM