Pass form-data from control to different page
Hi,
on our site we have several small search-forms (on different pages) which I want to encapsulate in a usercontrol.
The result of the search should be displayed in a different page (URL) which contains another usercontrol for search-results.
I have two questions about this scenario:
1. What would be the best way to transfer the search-paramters entered in the search-usercontrol to the searchresult-usercontrol (on a different page)? I do not want to pass the information as a querystring, because I have to prevent any automated retrieval of information from our site.
2. Where could I store the URL of the result-page, so that the search-controls don't have to be configured everytime they are placed on a page. I know that I could store the URL in the web.config... but if the URL of the result-page should change, the web.config would have to be changed manually. Could I use Tags on the result-page so that the search-control could find them in the sitemap. I'm looking for an elegant way here :)
Thank you for your help.
Regards
Hello SolarX,
Thank you for using our services.
You have two other options for passing the search parameters to the other page - through SessionState or cookies. The difference between both is that session is stored on the server and cookies on the client. The preferable approach to us is the SessionState.
When you expose properties for your user controls you can always define default values for those properties or if the property is not set you can set it to a value you want to be default:
private
string
resultsPage;
[DefaultValue(
"~/resultspage.aspx"
)]
public
string
ResultsPage
get
return
this
.resultsPage;
set
this
.resultsPage = value;
private
string
resultsPage;
public
string
ResultsPage
get
if
(String.IsNullOrEmpty(
this
.resultsPage))
this
.resultsPage =
"~/resultspage.aspx"
;
return
this
.resultsPage;
set
this
.resultsPage = value;