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
C#
Test de verificare a cunostintelor - editeaza
Sectiunea 1
Sectiunea 2
..................and code behind
C#
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);
}

Lokesh VarmanRank #374 · 6.8K reputationPosted Jul 23, 2023, 9:11 AM EDT
The issue with the buttons (
btnSec1andbtnSec2) not firing when clicked is likely due to the fact that they are outside theUpdatePanel. TheUpdatePanelis designed to perform partial page updates and enable partial rendering of the content inside it without causing a full postback. However, controls outside theUpdatePanelwon't be affected by it, and their events won't trigger partial postbacks.To make the buttons work properly, you have two options:
you can move the buttons
btnSec1andbtnSec2inside theUpdatePanel. This way, their events will trigger partial postbacks, and the content inside theUpdatePanelwill update without causing a full page refresh.If you prefer to keep the buttons outside the
UpdatePanel, you can usePostBackTriggerto explicitly define which controls outside theUpdatePanelshould cause a full postback instead of a partial postback.Marius VasileRank #785 · 2.9K reputationPosted Jul 23, 2023, 10:35 AM EDT
Thank you Lokesh, I got the idea it's clear now