简体   繁体   中英

OnClick event not working for linkbutton in a master page

This is the html ,

<asp:LinkButton ID="hlnkLogoffF" runat="server" Text="Logoff" OnClick="hlnkLogoffF_Click" ></asp:LinkButton>

This is the code behind,

protected void hlnkLogoffF_Click(Object sender, EventArgs e)
{
    //do something here
}

When i run this, i get the following error,

"The resource cannot be found. "

You have to use

if (!Page.IsPostBack)
{
      // Your code here
}

in code behind of master page.

Also

What happens if you turn off validating with CausesValidation setting to false?

i tried to run your code

.aspx

  <asp:LinkButton ID="hlnkLogoffF" runat="server" Text="Logoff"     OnClick="hlnkLogoffF_Click" ></asp:LinkButton>

.Cs

    protected void hlnkLogoffF_Click(object sender, EventArgs e)
    {

    }

i Haven't get any error.Could you please post the code inside the click event.?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM