Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Executing search function in page load event instead of button click

1 view
Skip to first unread message

VT Venkatesh

unread,
Aug 4, 2008, 5:11:58 AM8/4/08
to
I have a search entry page in which a user control (with a search text
box & a submit button)
When the search word is entered in the text box & the submit button are
pressed the following code is executed
******************************************
if tbSearch.Text.Length > 0 then
begin
errorLabel.visible:=false;
Response.Redirect('SpiderSearchShow.aspx?'+searchWord+'='
+Server.UrlEncode (tbSearch.text));
end
else
begin
errorLabel.Text:='Please enter some search text';
errorLabel.visible:=true;
end;
******************************************
Then i want the SpiderSearchShow.aspx to display the search results
based on the search criteria when the page loads.
Though I have written the search criteria code in the page load
event,the search does not take place unless i explicitly code the search
code in button Click vent handler & click the button.
How to ensure that the code gets executed in the page load event itself.
I know i am missing some thing very simple here:)
venkatesh

Nick Crisp

unread,
Aug 4, 2008, 8:36:39 AM8/4/08
to
Hi Venkatesh

I believe that in the page_load event, the viewstate of the controls has not
been restored. So during the page_load, your textbox has no value.

Why do you need to execute the search in the page_load instead of the
on_click?

Regards

Nick

"VT Venkatesh" <ve...@vsnl.com> wrote in message
news:4896...@newsgroups.borland.com...

VT Venkatesh

unread,
Aug 4, 2008, 9:38:35 AM8/4/08
to
Marc Rohloff [TeamB] wrote:
>
>
> Why are you using a redirect page? You should have the button call the
> destination page directly using the PostbackUrl property of the
> button.
>
Hi Marc
Thanks for the tip.How does one then pass the search value?.I am passing
it now as a queryString along with the redirect
Venkatesh

Marc Rohloff [TeamB]

unread,
Aug 4, 2008, 9:20:54 AM8/4/08
to
On Mon, 04 Aug 2008 18:50:45 +0530, VT Venkatesh wrote:

> The user inputs the search text in the home page & the search results
> have to be displayed in another page (both use the same user control
> with a text box & a search button) & for that to happen i need to run
> the search related code in the page load event.
> Is there any other way to run it?

Why are you using a redirect page? You should have the button call the
destination page directly using the PostbackUrl property of the
button.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

VT Venkatesh

unread,
Aug 4, 2008, 9:20:45 AM8/4/08
to
Hi Nick

The user inputs the search text in the home page & the search results
have to be displayed in another page (both use the same user control
with a text box & a search button) & for that to happen i need to run
the search related code in the page load event.
Is there any other way to run it?

Venkatesh

Marc Rohloff [TeamB]

unread,
Aug 4, 2008, 9:38:53 AM8/4/08
to
On Mon, 04 Aug 2008 19:08:35 +0530, VT Venkatesh wrote:

> Thanks for the tip.How does one then pass the search value?.I am passing
> it now as a queryString along with the redirect

Look at the help for PostbackUrl and the associated properties, it
should explain what you need to look at.

VT Venkatesh

unread,
Aug 4, 2008, 2:35:07 PM8/4/08
to
Marc Rohloff [TeamB] wrote:

> Look at the help for PostbackUrl and the associated properties, it
> should explain what you need to look at.
>

I tried to use the concept from
http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx
I declared a property searchString in searchpage.aspx & tried to access
the property searchString in searchpageResults.aspx through
previouspage.searchString
How ever searchString property does not show up in searchpageResults.aspx
I have declared the previouspageType directive in searchpageResults.aspx
Venkatesh

Marc Rohloff [TeamB]

unread,
Aug 4, 2008, 3:08:26 PM8/4/08
to
On Tue, 05 Aug 2008 00:05:07 +0530, VT Venkatesh wrote:

> How ever searchString property does not show up in searchpageResults.aspx
> I have declared the previouspageType directive in searchpageResults.aspx

This is not something people commonly do so code completion might not
show you the properties. If you type the property in it should
compile, otherwise do something like:
(PreviousPage as SearchPage).SearchString

VT Venkatesh

unread,
Aug 4, 2008, 11:07:36 PM8/4/08
to
Marc Rohloff [TeamB] wrote:
>
>
> This is not something people commonly do so code completion might not
> show you the properties. If you type the property in it should
> compile, otherwise do something like:
> (PreviousPage as SearchPage).SearchString

This is not working at all.Even (PreviousPage as
SearchPage).SearchString does not compile
Even the diective <%@ PreviousPageType VirtualPath = "~/SearchPage.aspx"
%> is showing an error 'Incomplete tag found at line 1' though this is
at line 3.when i remove the directive the error goes away
Is this a bug with the editor ?
Venkatesh


>

Marc Rohloff [TeamB]

unread,
Aug 5, 2008, 8:22:06 AM8/5/08
to
On Tue, 05 Aug 2008 08:37:36 +0530, VT Venkatesh wrote:

> This is not working at all.Even (PreviousPage as
> SearchPage).SearchString does not compile
> Even the diective <%@ PreviousPageType VirtualPath = "~/SearchPage.aspx"
> %> is showing an error 'Incomplete tag found at line 1' though this is
> at line 3.when i remove the directive the error goes away

> Is this a bug with the editor ?

Possibly, I have never seen anyone try to use this directive in
Delphi.NET before. You can skip the directive and just typecast
PreviousPage to whatever you need. Other solutions that might work
are:
* Add a button click event to SearchPage.aspx, IIRC, if you refer to
PreviousPage in SearchPageResults then it will cause the event to
fire.
* The article you linked to also provides a solution using
PreviousPage.FindControl

VT Venkatesh

unread,
Aug 5, 2008, 2:27:34 PM8/5/08
to
Marc Rohloff [TeamB] wrote:

> Possibly, I have never seen anyone try to use this directive in
> Delphi.NET before. You can skip the directive and just typecast
> PreviousPage to whatever you need. Other solutions that might work
> are:
> * Add a button click event to SearchPage.aspx, IIRC, if you refer to
> PreviousPage in SearchPageResults then it will cause the event to
> fire.
> * The article you linked to also provides a solution using
> PreviousPage.FindControl
>

PreviouPage always returns nil in delphi.net.
I tried it in VS & it works great.How to confirm whether previouspage
works though the the word is recognised & it compiles ok.
Can some one test this out ?
Venkatesh

0 new messages