title: How to detect the current URL and then forward based on it
body: <p>I have a textbox and an image button as follows</p>
  
  <pre><code>&lt;asp:TextBox ID="myText" runat="server"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:ImageButton ID="btnExecute" runat="server" OnClick="btnExecute_Click" /&gt;
  </code></pre>
  
  <p>Now here is my problem, on the Page_Load there are some bindings.. and these bindings go into dozens of controls and classes, by the time it's about to reach my code in the <code>On_Click</code> for my button its too late.. it would redirect to somewhere else.. I needed to redirect to a different page but it would never reach its destination unless i somehow ommit all the stuff in between which i am not willing to do..</p>
  
  <p>So, the solution that i thought is to use Javascript on that image button <code>OnClientClick</code>, unfortunately I am not so good at it and was hoping you could help me.. the pseudo code would be something like this</p>
  
  <pre><code>if(the current url contains some page.aspx)
        {
            var value = get the value from myText;
  
            then navigate to  myotherpage?txtvalue=value;
        }
  </code></pre>
  
  <p>Can someone help me with this javascript without going into to much details on why i am doing it like this? please</p>
  
  <p>I would really appreciate it.</p>
  
  <p>Thank you</p>