[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
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?
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:
If a or b or not page.ispostback Then
[INDENT]DoAction()
DoAction2()[/INDENT]
End If
it should be:
VB Code:
If a or b Then
[INDENT]If Not Page.IsPostBack Then
[INDENT]DoAction()
DoAction2()[/INDENT]
End If[/INDENT]
End If