Linking pages using link buttons
Hi everyone, :wave:how are you all doing?Me, I am just trying to survive.Anyway i was wondering if you can be able to help me on how to link pages on the same website using link button control.Pliz do not be too technical since I just discovered ASP.NET last week!!! :thumb:
Re: Linking pages using link buttons
There are two controls that will do what you want: Link Button and HyperLink.
The LinkButton is treated like a button in the fact that pressing it triggers a server-side method (OnClick). When you actually look at the HTML code generated it uses JavaScript to do this and therefore unless there is a good reason I don't use them. If you are just linking to other pages just use the HyperLink control.
LinkButton example:
Code:
<script runat="server">
void btnLink_Click(object sender, EventArgs e) {
Response.Redirect("page2.aspx");
}
</script>
<asp:LinkButton id="btnLink" runat="server" OnClick="btnLink_Click" Text="Click here" />
Hyperlink example:
Code:
<asp:HyperLink id="lnk1" runat="server" NavigateUrl="page2.aspx" Text="Click here" />
Give me a shout if you have any other problems.
DJ