title: Javascript on my ASCX control is not redirecting me to a new page/control
body: <p>We have a website built with controls for all our tasks/pages.
  Each control has a page id (pid) that we then click on the relevant link to go to that page.</p>
  
  <p>On my page, I have a button that loads data for that page, but I want to redirect people before the code runs.</p>
  
  <p>In essence, the client logs in and starts ordering. When the add to cart button is clicked, before the code-behind loads all items onto the cart, if the user is not opted to place this order, they must be warned and redirected accordingly.</p>
  
  <p>So far, on my button, I have:</p>
  
  <pre><code>&lt;asp:LinkButton CssClass="Button" Font-Bold="True" Text="Load Lines" runat="server" 
  ID="btnVerifyOrder" OnClientClick='checkIsOptedIn();' /&gt;
  </code></pre>
  
  <p>And the javascript is:</p>
  
  <pre><code> &lt;script language="javascript" type="text/javascript"&gt;
      function checkIsOptedIn() {
          var str = window.location.href;
          var url = str.substring(0, str.length - 2);
          var value = $('#&lt;%=hidIsOptIn.ClientID %&gt;').val();
  
          if (value == "False") {
              var question = confirm("You are not opted in for ordering to continue processing this. If you would like to view and complete the form, please click OK. Or click Cancel reload the page");
              if (question == true) {
                  url = url + "6";
                  window.location.replace(url); //this will not work
                  window.location.href = url; //or this
              } else {
                  url = url + "32";//the current pid of the control. So they just refresh here at the beginning, but this doesn't refresh the page at the top either
                  window.location.href = url;
              }
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>And there is code behind the button click as well:</p>
  
  <pre><code> Protected Sub btnVerifyOrder_Click(sender As Object, e As EventArgs) Handles btnVerifyOrder.Click
          Page.MaintainScrollPositionOnPostBack = True
          'Do code work then
          GenerateClaimLines()
   End Sub
  </code></pre>
  
  <p>Now when I run the page on my localhost and login as a client that is not opted, I see the message and click OK, but the control being called is not loaded. Instead the current page loads with the code behind as if the client can place the order.</p>
  
  <p>Can some one please explain why the page will not redirect. I have tried to go to the host address, Google, anything, yet I will not be redirected. Also, if they click Cancel, the page should be redirected the the same page, but at the beginning of the process, so nothing is loaded, just the default data. Yet this doesn't load either.</p>
  
  <p>Must I return a variable boolean from the jscript function? Or do something else here?</p>