T
Torben Philippsen
Hi,
I have a very simple searchform (an asp:textbox and a asp:button)
I have enabled autopostback for the textbox to be able to execute the search
method when the user hits the enter key.
Ofcourse the search should also be executed when clicking the search button.
Therefore I have added an empty eventhandler to recieve the click event. The
eventhandler is empty because I handle the postback in the page_load event:
if (Page.isPostBack)
{
search();
}
else
//do nothing - it's the first time the page is loaded
The problem is when I hit the search button the postback event is raised two
times, causing the search() method to be executed two times, which means
that the search result is being doubled.
If I hit the enter key after having entered something into the textbox, the
search method is executed just one time - as it should. How can I make sure
that the search method is only being executed one time no matter if it was
the enter key or the search button that was pressed/clicked by the user?
Thank you very much for your help.
Regards
Torben Jensen
I have a very simple searchform (an asp:textbox and a asp:button)
I have enabled autopostback for the textbox to be able to execute the search
method when the user hits the enter key.
Ofcourse the search should also be executed when clicking the search button.
Therefore I have added an empty eventhandler to recieve the click event. The
eventhandler is empty because I handle the postback in the page_load event:
if (Page.isPostBack)
{
search();
}
else
//do nothing - it's the first time the page is loaded
The problem is when I hit the search button the postback event is raised two
times, causing the search() method to be executed two times, which means
that the search result is being doubled.
If I hit the enter key after having entered something into the textbox, the
search method is executed just one time - as it should. How can I make sure
that the search method is only being executed one time no matter if it was
the enter key or the search button that was pressed/clicked by the user?
Thank you very much for your help.
Regards
Torben Jensen