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

removing query string items from url?

3 views
Skip to first unread message

jobs

unread,
Apr 2, 2007, 4:51:01 PM4/2/07
to
I have a gridview with data that's a link to another page.

I want to pass search information to the called page, but I don't want
that query string to remain in the address line beyond the initial
call.

Say my like looks like this, mypage.aspx?search="whatever"

should my users make a selection on the page or even refresh, I want
the ?search to go away.. what's the best way to address this

without forcing a response redirect?

Thanks for any help or information.

Alexey Smirnov

unread,
Apr 2, 2007, 5:00:07 PM4/2/07
to

Maybe you can use HTTP POST instead of GET method? In this case you
can call mypage.aspx without using querystring...

Example:

<form action="mypage.aspx" method="post">
<input type="text" name="search" value="whatever" />
<input type="submit" value="search" />
</form>

jobs

unread,
Apr 2, 2007, 5:56:54 PM4/2/07
to

> <form action="mypage.aspx" method="post">
> <input type="text" name="search" value="whatever" />
> <input type="submit" value="search" />
> </form>

Thanks for that.. thinking about how this will work and what the
impact might be.

the hyperlink is inside a gridview on content page. The form, is on
the master page and will control many pages and controls. I'm not sure
how I would even set the id search to whatever from the gridview.

thank you.

Alexey Smirnov

unread,
Apr 2, 2007, 6:34:49 PM4/2/07
to

Well, what about a LinkButton Control instead of normal hyperlink?
The LinkButton posts the web form back.

in the grid

<asp:LinkButton
ID="Button1"
CommandArgument="whatever"
Text="Search">
runat="server" />

in the code-behind

protected void EditContent(object sender, CommandEventArgs e)
{
//e.g. use Session
Session["search"] = e.CommandArgument.ToString();
Response.Redirect("~/mypage.aspx");
}

OR there is also another way to use the PostBackUrl property

<asp:LinkButton ID="Button1"
PostBackUrl="~/mypage.aspx"
runat="server"
Text="Search" />

to pass the value: http://msdn2.microsoft.com/en-us/library/ms178139(VS.80).aspx

0 new messages