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
Test de verificare a cunostintelor - editeaza
Sectiunea 1
Sectiunea 2
..................
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);
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Lokesh VarmanPosted Jul 23, 2023, 1:11 PM
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 VasilePosted Jul 23, 2023, 2:35 PM
Thank you Lokesh, I got the idea it's clear now