That makes sense. I initially had it redirecting.
Would it be just as good to add the query string check into the click handler
for the Search button?
if (!String.IsNullOrEmpty(queryString)) {
Button1.PostBackUrl = queryString;
}
And would Request.QueryString.Remove("k") be just as effective?
Regards,
Paul
From: [email protected] [mailto:[email protected]] On Behalf Of
James Boman
Sent: Tuesday, 2 September 2014 9:51 AM
To: ozMOSS
Subject: RE: Passing query string param to filter expression on ObjectDataSource
Paul,
HttpContext.Current.Request.QueryString.Clear();
This will clear the querystring on the request object that is about to be
destroyed, so is probably not going to be a strategy that will work. You might
want to look into modifying the response object, but probably more likely to
succeed is something like
this<http://blogs.msdn.com/b/tinghaoy/archive/2005/12/22/506852.aspx> where you
can alter the query string by setting the PostBackUrl on the search button on
your page.
Cheers,
J.
________________________________
James Boman ■ Phone: +61872001100<callto:+61872001100> ■ Mobile:
+61417857298<callto:+61417857298> ■ Skype: JDBoman<callto:JDBoman> ■ Web:
www.ipmo.com.au<http://www.ipmo.com.au/>
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Paul Noone
Sent: Tuesday, 2 September 2014 8:45 AM
To: ozMOSS
Subject: RE: Passing query string param to filter expression on ObjectDataSource
Hi Prashanth,
Redirecting to the target page and appending the query is no problem.
However the Staff Lookup web part on the target page is a custom part. I want
to perform a search on page load if the key/value is present and then clear it
on postback. Hope that makes sense.
Regards,
Paul
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Prashanth Thiyagalingam
Sent: Monday, 1 September 2014 8:11 PM
To: ozMOSS
Subject: Re: Passing query string param to filter expression on ObjectDataSource
If you are using OOTB search web part then you can do this in client side, get
the query string in js and then do a redirection to the target page with the
query string value
Cheers,
Prashanth
Sent from my iPhone
On Sep 1, 2014, at 1:58 PM, "Paul Noone"
<[email protected]<mailto:[email protected]>> wrote:
Hi all,
I have a custom people search web part which uses a simple form, SPGrid and a
DataTable.
<image003.jpg>
I’d like to extend this so that people can search for staff from another page
via a Search Box.
<image004.png> …where k=”Paul"…
What I want to do is:
1. Check if the "k" param has a value.
2. Use it in my query and apply it to the datasource’s filter expression.
3. Clear the query string on postback.
I’ve added the following to the OnLoad event but it throws a NullReference
exception.
Any help appreciated.
// Get URL and check for "k" query string param in case of search from another
page
String txtNameFromQuery = HttpContext.Current.Request.QueryString["k"];
if(!String.IsNullOrEmpty(txtNameFromQuery))
{
// Set txtName field to query string value for additional searches
txtName.Text = txtNameFromQuery;
// Define the search query
String q = "Name LIKE '%" + txtNameFromQuery + "%'";
// Apply query to filterexpression
ds.FilterExpression = q;
ViewState["FilterExpression"] = (String)ds.FilterExpression;
// Remove any query string parameters from the URL
HttpContext.Current.Request.QueryString.Clear();
}
Regards,
Paul
The content of this email is confidential to the intended recipient at the
email address to which it has been addressed. It may not be disclosed to, or
used by, anyone other than this addressee, nor may it be copied in any way. If
received in error, please contact the author and then delete the message from
your system.
Please note that neither Keller Australia nor the sender accepts any
responsibility for viruses and it is your responsibility to scan the email and
attachments (if any).
Visit http://www.keller.com.au/ for more information.
________________________________
This e-mail message has been scanned for Viruses and Content and cleared by
MailMarshal
________________________________
_______________________________________________
Sponsored by Infotext - Amazing Search for Microsoft SharePoint -
http://www.infotext.com/
ozmoss mailing list
[email protected]<mailto:[email protected]>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
The content of this email is confidential to the intended recipient at the
email address to which it has been addressed. It may not be disclosed to, or
used by, anyone other than this addressee, nor may it be copied in any way. If
received in error, please contact the author and then delete the message from
your system.
Please note that neither Keller Australia nor the sender accepts any
responsibility for viruses and it is your responsibility to scan the email and
attachments (if any).
Visit http://www.keller.com.au/ for more information.
________________________________
This e-mail message has been scanned for Viruses and Content and cleared by
MailMarshal
________________________________
The content of this email is confidential to the intended recipient at the
email address to which it has been addressed. It may not be disclosed to, or
used by, anyone other than this addressee, nor may it be copied in any way. If
received in error, please contact the author and then delete the message from
your system.
Please note that neither Keller Australia nor the sender accepts any
responsibility for viruses and it is your responsibility to scan the email and
attachments (if any).
Visit http://www.keller.com.au/ for more information.
--------------------------------------------------------------------------------
This e-mail message has been scanned for Viruses and Content and cleared by
MailMarshal
--------------------------------------------------------------------------------
_______________________________________________
Sponsored by Infotext - Amazing Search for Microsoft SharePoint -
http://www.infotext.com/
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss