Results 1 to 3 of 3

Thread: [RESOLVED] imagebutton runs first page_load

  1. #1

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Resolved [RESOLVED] imagebutton runs first page_load

    Hello all,

    I'm having a problem, and I'm sure someone could help me with this:

    in an ASP .NET application I have several imagebuttons. I have a problem with them. Every time I click a button, the page load event is called instead of the method specified in the OnClick of the button...

    what could be the base of this problem? I can't find it, but because it's a heavy application, each time I call the form, it is loaded twice instead of once.

    The methods provides some action to the database, and then redirects to the same page with other parameters.

    Does someone have a suggestion?

    Thanx in advance,

    Marco

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

    Re: imagebutton runs first page_load

    The Page Load event will always be called, everytime there is a postback. You should enclose the run-once-only code in your Page_Load event in a Page.IsPostBack check.

    Does it call the image button's click event eventually?

  3. #3

    Thread Starter
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310

    Re: imagebutton runs first page_load

    Well, I've searched, and searched, and searched... didn't find. Until tomorrow... Now I see what was going wrong:
    VB Code:
    1. If a or b or not page.ispostback Then
    2. [INDENT]DoAction()
    3. DoAction2()[/INDENT]
    4. End If

    it should be:
    VB Code:
    1. If a or b Then
    2. [INDENT]If Not Page.IsPostBack Then
    3. [INDENT]DoAction()
    4. DoAction2()[/INDENT]
    5. End If[/INDENT]
    6. End If

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