I'm working on ASP.NET Web Forms application. I have an UpdatePanel inside which I have a TextBox and a Button :
<asp:UpdatePanel ID="MyID"
UpdateMode="Always"
runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnId"/>
</Triggers>
<ContentTemplate>
<asp:Label id="LblId" Text="The total value is:" runat="server" />
<asp:TextBox ID="txtId" Text="" readonly="true" runat="server"></asp:TextBox>
<asp:button id="btnId" Text="Calculate" runat="server" onclick="btnId_Click"/>
</ContentTemplate>
on my code behind I have a handler :
protected void btnId_Click(object sender, EventArgs e)
{
txtId.Text = ..
}
The problem that I have is that when I click the Calculate button it first goes through some(maybe all init events) of the page like Page_Load which I was able to check with the debugger so before my btnId_Click is executed My code firs got through :
protected void Page_Load(..)
{
...
if (Page.IsPostBack)
{
...
}
}
which is troublesome since I have some logic there which I don't want to be executed when this button is clicked instead, perfectly I would want only the code inside btnId_Click handler to be executed and that to be all. How can achieve something like this?