Link Button does not always work in codebehind
Posted on 2003-11-21
I have two Web "linkbuttons" and a label on my aspx page as follows:
<asp:LinkButton id="HomeLinkButton" runat="server">Home</asp:LinkButton>
<asp:LinkButton id="PreviousLinkButton" runat="server">Previous</asp:LinkButton>
<asp:Label id="lblResult" runat="server"></asp:Label>
In the codebehind C# page, I have them both declared properly as follows:
protected System.Web.UI.WebControls.LinkButton HomeLinkButton;
protected System.Web.UI.WebControls.LinkButton PreviousLinkButton;
protected System.Web.UI.WebControls.Label lblResult;
In the onlick events of each, i have the following:
private void HomeLinkButton_Click(object sender, System.EventArgs e)
lblResult.Text = "Clicked Home Link";
private void PreviousLinkButton_Click(object sender, System.EventArgs e)
lblResult.Text = "Clicked Previous Link";
When I click on the "Previous" Link, the label is updated.
When I click on the "Home" link, it is not.
I have refreshed the page and clicked in different orders. No difference.
I have even made a third function that is called from each of the onlcick events. No change.
Please tell me how to make this work?