title: How to change URL on button click without page redirect in asp.net
body: <p>I have a page similar to <strong><a href="https://www.gazelle.com/sell/cell-phone" rel="nofollow">this link</a></strong> which list items. All works fine. Just i am not able to rewrite the <code>URL</code> of a <code>page</code> on button clicked at different Levels.</p>
  
  <p>EG:
  when i click on <code>Button</code> "CellPhone" on <code>Level1 div</code> and later on click on <code>Button</code> "BlackBerry" which is on <code>Level2 div</code> then <code>URL</code> must be <code>"www.somesite.com/cellphone/blackberry"</code> and again when i <code>click on Button</code> "cellphone" i must change <code>URL</code> to <code>"www.somesite.com/cellphone"</code> </p>
  
  <p>Please can any one suggest me to do the same in <code>asp.net.</code></p>
  
  <p><strong>Note:</strong> <strong>I am using Visual Studio 2008 Framework 3.5</strong></p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>function changeState(num) {
              var stateObj = { foo: "Default" };
              //alert(window.history.length);
              if (num == 1) {
                  alert("cellphone");
                  window.history.replaceState(stateObj, "HtmlPage", "Cellphone");
                  Show("divLevel2");
              }
              else if (num == 2) {
                  alert("sprint");
  
                  window.history.replaceState(stateObj, "HtmlPage", "CellPhone/Sprint");
                  Show("divLevel3");
  
              }
              else if (num == 3) {
                  alert("iphone6");
                  Show("divLevel3");
               window.history.replaceState(stateObj, "HtmlPage","CellPhone/Sprint/iPhone6");
  
  
              }
          }
          $(document).ready(function() {
              HideAll();
  
          });
          function Show(divid) {
              $("#" + divid).css("display", "block");
  
          }
          function HideAll() {
              $("#divLevel2").css("display", "none");
              $("#divLevel3").css("display", "none");
  
          }
  </code></pre>
  
  <p><strong>ASPX MARKUP:</strong></p>
  
  <pre><code> &lt;div class="divMain" class="box"&gt;
          &lt;div id="divLevel1" class="box"&gt;
              &lt;asp:UpdatePanel runat="server" ID="updatePanelLevel1"&gt;
                  &lt;Triggers&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:Button ID="Button1" runat="server" Text="CellPhone" class="Button1" OnClick="Button1_Click"
                          ForeColor="Black" /&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
          &lt;/div&gt;
          &lt;div id="divLevel2" class="box"&gt;
              &lt;asp:UpdatePanel runat="server" ID="updatePanelLevel2"&gt;
                  &lt;Triggers&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:Button ID="Button2" runat="server" Text="Sprint" class="Button2" OnClick="Button2_Click"
                          ForeColor="Black" /&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
          &lt;/div&gt;
          &lt;div id="divLevel3" class="box"&gt;
              &lt;asp:UpdatePanel runat="server" ID="updatePanelLevel3"&gt;
                  &lt;Triggers&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:Button ID="Button3" runat="server" Text="iPhone6" class="Button3" OnClick="Button3_Click"
                          ForeColor="Black" /&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p><strong>Pagename.ASPX.CS</strong></p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
      {
          ScriptManager.RegisterStartupScript(this, GetType(), "myFunction1", "changeState(1);", true);
      }
      protected void Button2_Click(object sender, EventArgs e)
      {
          ScriptManager.RegisterStartupScript(this, GetType(), "myFunction2", "changeState(2);", true);
      }
      protected void Button3_Click(object sender, EventArgs e)
      {
          ScriptManager.RegisterStartupScript(this, GetType(), "myFunction3", "changeState(3);", true);
      }
  </code></pre>
  
  <p><strong>When i click on "iPhone6" button the click event doesnt fire! any idea?</strong></p>