asp.net - Parameter removed from the query string is shown in the browser the first time -


i'm working on asp.net web forms app. in moment have navigate page javascript using

window.location = '/clients/edit.aspx?clientid=' + id; 

which leads url - http://localhost:5870/clients/edit.aspx?clientid=1. bit misleading because once i'm on edit page may chose edit client , next time using ajax request url stays id of first user. instead of looking way show correct id (the user don't need info) prefer remove it's not misleading @ least. in edit page have code:

 protected void page_init(object sender, eventargs e)  {    if(!ispostback)    {      system.reflection.propertyinfo isreadonly =        typeof(system.collections.specialized.namevaluecollection).getproperty(        "isreadonly", system.reflection.bindingflags.instance |           system.reflection.bindingflags.nonpublic);         // make collection editable         isreadonly.setvalue(this.request.querystring, false, null);         // remove         this.request.querystring.remove("clientid");    }   } } 

which working. when page loaded first time still clientid=.. in url it's cleaned. don't want show @ all.

assume have url: http://localhost:5870/clients/edit.aspx?clientid=1

can use js code:

<script>     window.history.pushstate('obj', '', '.'); </script> 

output: http://localhost:5870/clients/


or use this:

<script>     window.history.pushstate('obj', '', 'edit.aspx'); </script> 

output: http://localhost:5870/clients/edit.aspx

note: consider changes aren't valid process , show, can't use them new quesrystring , if try querystring's value original querystring original url.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -