user3526696 user3526696 - 3 months ago 28
ASP.NET (C#) Question

How to update query string and reload Page on DropDownList SelectedIndexChanged event?

have Dropdownlist which have languages how to reload page each time change selected item from dropdown ?

protected void DDLLanguages_SelectedIndexChanged(object sender, EventArgs e)
{
if (Request.RawUrl.Contains("Language") == false )
{
Response.Redirect(Request.RawUrl + "?Language=" + DDLLanguages.SelectedValue);
}
else
{
//i need to update the quesry string here

}

}

Answer
 protected void DDLLanguages_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Request.RawUrl.Contains("Language") == false )
            {
                Response.Redirect(Request.RawUrl + "?Language=" + DDLLanguages.SelectedValue);
            }
            else
            {
             //i need to update the quesry string here 
   Response.Redirect(Request.Url.GetLeftPart(UriPartial.Path)+ "?Language=" + DDLLanguages.SelectedValue);

            }

    }