Results 1 to 2 of 2

Thread: Linking pages using link buttons

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    1

    Question Linking pages using link buttons

    Hi everyone, 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!!!

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    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

    If I have been helpful please rate my post. If I haven't tell me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width