title: ASP.NET CheckBox state and PostBack
body: <p>I have a simple task - to change page link on checkbox state change - but I'm new to ASP.NET and have some trouble.</p>
  
  <p>I can do the same using HtmlControl and JavaScript:</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
    function checkbox_onChanged(checked) {
      if (checked) {
        document.location = '?type=request_in&amp;show=all';
      }
      else {
        document.location = '?type=request_in&amp;show=unapproved';
      }
    }
  
    function checkbox_onLoad(checkbox) {
      checkbox.checked = true;
    }
  &lt;/script&gt;
  
  &lt;form action="" method="get"&gt;
  &lt;input type="checkbox" name="checkbox"
    onload="checkbox_onLoad(this)"
    onchange="checkbox_onChanged(this.checked)" /&gt;Show all
  &lt;/form&gt;
  </code></pre>
  
  <p>but I want to hide it from users. So I do:</p>
  
  <pre><code>&lt;asp:CheckBox runat="server" ID="check" 
    OnCheckedChanged="check_CheckedChanged"
    AutoPostBack="True" Text="Show all" /&gt;
  
  protected void check_CheckedChanged(object sender, EventArgs e)
  {
    Response.Redirect(String.Format("{0}?type=request_in&amp;show={1}", Request.Path, 
    checkViewRequestIn.Checked ? "all" : "unapproved"));
  }
  
  protected void Page_Load(object sender, EventArgs e)
  {
    var show = Request["show"];
    if (!String.IsNullOrEmpty(show) &amp;&amp; String.Equals(show, "all"))
    {
      checkViewRequestIn.Checked = true;
    }
  }
  </code></pre>
  
  <p>But it seems that check state change on load raises the event again and checkbox becomes checked always!</p>
  
  <p>Ans another question - is there any other way to redirect to the same page without giving it's filename? I mean like in JavaScript - only giving variables needed?</p>