Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, July 11, 2010 10:45 AM
I want to have a page that was accessed by a QueryString refresh the page with a new selection from a DropDownList
and remove the QueryString from the Url.
Example:
the page was accessed by this url
http://forums.asp.net/AddPost.aspx?ForumID=24
When the user selects a value from a DropDownList the page is refreshed
without the ?ForumID=24
http://forums.asp.net/AddPost.aspx
OR
the user is refreshs the page with a New QueryStringValue
http://forums.asp.net/AddPost.aspx?ForumID=99
All replies (6)
Sunday, July 11, 2010 3:34 PM ✅Answered
Do you have if(!IsPostBack) when you are loading the DropDownlist
if(!IsPostBack)
{
// Load your dropdownlist
}
otherwise, everytime page loads, your DDL will be loaded and lose your selection.
Monday, July 12, 2010 12:11 AM ✅Answered
Hi,
Is your ddlSelect_SelecttedIndexChanged event is being fired? If not you should enable the autopostback property of the dropdown.
If you have done this already can you check if the binding of the dropdown is being happened in
if (!IsPostback)
{
// bind the ddlSelect
}
If all this is done, please paste your code here.
Thanks,
Anup
Sunday, July 11, 2010 12:27 PM
use reponse.redirect(request.path); for refresh same page without query string
Sunday, July 11, 2010 2:12 PM
Hi,
On change event of the dropdown, response.redirect to the same page with querystring as new value selected in dropdown.
I think this should solve your problem.
Thanks,
Anup Daware
Sunday, July 11, 2010 2:31 PM
I just tried that but for some reason teh DDL does not update the value on the changed event. I stepped through the code and it was not updated
protected void ddlSelect_SelecttedIndexChanged(object sender, EventArgs e)
{
String letterChoice = ddlSelect.SelectedValue.ToStrin();
Response.Redirect("customerShow.aspx?leterchoice="+letterChoice);
}
Should have a new updated value each time but it does not
Sunday, July 11, 2010 3:58 PM
Try these things, hope it works not sure in your case:-
--> After selection value from dropdown, go to page and go in the view source and see the error or value of dropdown, based on that you will get what happening exactly.
or
are you using ajax?