views:

56

answers:

4

The application i'm making starts Internet Explorer with a specific URL. for instance, this fake url:

&aqi=g10&aql="3"&oq="3"

how can i change that url into this one:

&aqi=g10&aql="2"&oq="2"

by using an item from a combobox?

What i'm trying to do is changing a part of the URL with selecting an item in a combobox and then executing the URL in IE.

anyone ideas?

(not sure if the title is right)

thanks in advance

+1  A: 

If I understood correctly what you're trying to do, you can get the query string parameters with Request.QueryString, do the manipulations as per the selections in the combobox, then build the new URL and redirect to it with Response.Redirect.

http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx

http://msdn.microsoft.com/en-us/library/t9dwyts4.aspx

Something like:

// get the URL from the Request and remove the query string part
string newUrl = Request.Url.ToString().Replace(Request.Url.Query, "");

newUrl += string.Format("?aqi={0}&aql={1}&oq={2}",
    Request.QueryString["aqi"], ddlAql.SelectedValue, ddlOq.SelectedValue);

Response.Redirect(newUrl);
Dan Dumitru
Can you give me an example with the url I supplied?
Erik
@Erik - I added a rough example.
Dan Dumitru
You should check that newUrl != original URL or you will be in an endless redirect.
jamietre
@jamietre: The only thing that would cause an endless redirect is if the redirect is executed as part of the page load.
Chris Lively
good point, he did say it was from a combobox.
jamietre
A: 

Build the url in code:

string url = "&aqi=g10&aql=\"" + comboBox1.Text + "\"&oq=\"" + comboBox2.Text + \"";
Peter van Kekem
what if I want to use a string instead of Combobox*.Text?
Erik
A: 

It works, but not right yet. Ive got this code:

+modified%22+\"" + txtUrl.Text + "\"+\"" + Convert.ToString(Extensie) + "\"+-faq+-

which gives in the URL:

modified%22+"beer"+".jpg"+-faq+-

but I dont want the quotes in the URL

which quotes do i have to delete in order to get this done?

Erik
A: 

My question is solved Thanks for the help!

Erik