Marius Vasile

Marius Vasile

  • 592
  • 1.9k
  • 145.9k

asp.net c# Button outside UpdatePanel not working

Jul 22 2023 7:06 AM

I have an .aspx page with a btn outside an UpdatePanel which is not firing. Nothing is happening if I click on btnSec1 or btnSec2. I tried in another page without UpdatePanel and is working. How should it be done? Thanks

<asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager" runat="server" />
   
    <div id="Div1" runat="server" visible="false">
        <div class="row no-gutters justify-content-center text-success">
            <p class="h3">Test de verificare a cunostintelor - editeaza</p>
        </div>
        <div class="row no-gutters justify-content-center">
            <div class="col-4 text-center">
                <div class="row no-gutters">
                    <asp:Button ID="btnSec1" OnClick="ShowSec1" runat="server" class="btn btn-link border-primary"  Text="Sectiunea 1 - Subiecte generale"  />
                </div>
            </div>
            <div class="col-4 text-center">
                <div class="row no-gutters">
                    <asp:Button ID="btnSec2" OnClick="ShowSec2" runat="server" class="btn btn-link border-primary"  Text="Sectiunea 2 - Subiecte specifice"  />
                </div>
            </div>
        </div>

        <div id="DivSec1" runat="server" visible="false">
            Sectiunea 1
        </div>

        <div id="DivSec2" runat="server" visible="false">
            Sectiunea 2
        </div>
        

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                ..................
            </ContentTemplate>
        </asp:UpdatePanel>

and code behind

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["Sectiune"] != null)
    {
        string sec = Request.QueryString["Sectiune"];
        if (sec == "Sec-1")
        {
            DivSec1.Visible = true;
            DivSec2.Visible = false;
        }
        else if (sec == "Sec-2")
        {
            DivSec1.Visible = false;
            DivSec2.Visible = true;
        }
        else
        {
            return;
        }
    }
}
protected void ShowSec1(object sender, EventArgs e)
{
    string t = "Sec-1";
    Response.Redirect("/AdminPages/AddData.aspx?Sectiune=" + t);
}
protected void ShowSec2(object sender, EventArgs e)
{
    string t = "Sec-2";
    Response.Redirect("/AdminPages/AddData.aspx?Sectiune=" + t);
}

 


Answers (2)