<p>I have a "showall" query string parameter in the url, the parameter is being added dynamically when "Show All/Show Pages" button is clicked. </p>

<p>I want the ability to toggle "showall" query string parameter value depending on user clicking the "Show All/Show Pages" button.</p>

<p>I'm doing some nested "if's" and <code>string.Replace()</code> on the url, is there a better way?</p>

<p>All manipulations are done on the server.</p>

<p><strong>p.s.</strong> Toran, good suggestion, however I HAVE TO USE URL PARAMETER due to some other issues.</p>

[{'answer_id': 45003, 'author': 'Toran Billups', 'author_id': 2701, 'author_profile': 'https://Stackoverflow.com/users/2701', 'pm_score': 0, 'selected': False, 'text': '<p>Another dirty alternative could be just to use a hidden input and set that on/off instead of manipulating the url.</p>\n'}, {'answer_id': 45028, 'author': 'chrisntr', 'author_id': 4455, 'author_profile': 'https://Stackoverflow.com/users/4455', 'pm_score': 0, 'selected': False, 'text': "<p>Would it be too much of an effort just to have the value hard-coded into the URL (I know it's not too nice) with a default value or true then just have </p>\n\n<p><code>booleanVar = !booleanVar;</code> </p>\n\n<p>run on every page load?</p>\n\n<p>At least that would move away from the need of having nested ifs to manipulate the URL. </p>\n"}, {'answer_id': 45032, 'author': 'Ian Patrick Hughes', 'author_id': 2213, 'author_profile': 'https://Stackoverflow.com/users/2213', 'pm_score': 0, 'selected': False, 'text': '<p>I am not sure based upon the question, but isn\'t this where <a href="http://msdn.microsoft.com/en-us/library/ms227675(VS.80).aspx" rel="nofollow noreferrer">HTTPHandlers</a> come to the rescue? Shouldn\'t you be handling the variable alteration on the object prior to page rendering in this case then?</p>\n'}, {'answer_id': 45034, 'author': 'bentford', 'author_id': 946, 'author_profile': 'https://Stackoverflow.com/users/946', 'pm_score': 3, 'selected': True, 'text': '<p>Just to elaborate on Toran\'s answer:</p>\n\n<p>Use:<br>\n    <code>&lt;asp:HiddenField ID="ShowAll" Value="False" runat="server" /&gt;</code></p>\n\n<p>To toggle your state:</p>\n\n<pre><code>protected void ToggleState(object sender, EventArgs e)\n{\n    //parse string as boolean, invert, and convert back to string\n    ShowAll.Value = (!Boolean.Parse(ShowAll.Value)).ToString();\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/44999', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3661/']