Results 1 to 5 of 5

Thread: [RESOLVED] LinkButton does not perform assigned code

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2008
    Posts
    18

    Unhappy [RESOLVED] LinkButton does not perform assigned code

    Hi!

    I have LinkButton object, which I need to load another page after been pressed. At the same time, there is a code assigned to it. Let's say, assigning a value to a variable.

    The funny thing is that when there is no URL yet assigned in Properties (PostBackUrl), then code is working fine. But as soon as I put there some link, button only work for this link, no code processed!

    Any ideas on this tricky one? How to force it to simultaneously assign value to a variable and then move to another page?
    Last edited by FreakyBoy; May 4th, 2008 at 04:59 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: LinkButton does not perform assigned code

    You should post your ASP.NET questions in the ASP.NET forum.

    The PostBackUrl is the page you want to post your data back to when the link is clicked. It sounds to me like you don't want to post back to a different page. You probably want to post back to the same page, so don't set the PostBackUrl. If you want the Click event of the LinkButton to be handled in the same page then you certainly do want to post back to the same page. You can then redirect to a new page from that event handler.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: LinkButton does not perform assigned code

    In the LinkButton's click event handler, do your processing, then Response.Redirect.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    May 2008
    Posts
    18

    Re: LinkButton does not perform assigned code

    Great! No need to use this LinkButton!

    Thanx!

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] LinkButton does not perform assigned code

    The point of a LinkButton is to look like a HyperLink and behave like a Button. If that's what you want then a LinkButton is exactly what you should use, otherwise not.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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