0

I try using href and posbackturl but it doesn't work . I started learning c# since last week so im still weak on it .Can anyone teach me how to solve it ?

<button class="button" style="vertical-align:middle"><span>Add Contact </span></button>
Lau Weiqi
  • 45
  • 1
  • 7

1 Answers1

1

If you want to simply redirect to to the page, then simply you can forward it by just providing the page to href.

<a href="addcontact.aspx" style="vertical-align:middle" role="button">Add Contact</a>

If you simply want to redirect you can use LinkButton.

<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/addcontact.aspx">Add Contact</asp:LinkButton>

And if you want to perform some functionality on server side, then you may have to use OnClick event to bind with button which will look like this. Web Form

<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Add Contact</asp:LinkButton>

C# Server Side

protected void LinkButton1_Click(object sender, EventArgs e)
{
   //Functionaltiy
   Response.Redirect("/addcontact.aspx");
}

I hope this will solve your problem.

Jawad Anwar
  • 485
  • 4
  • 15