title: Need help Toggle Button in AJAx in ASP.net
body: <p>I want the page to be updated each time the checkbox is checked or unchecked (which is using the Toggle Button from AJAX). But I am not able to do so. I tried doing the same with a button and an imagebutton, they work great( but i faced problem when I tried to update the toggle button in the "onclick" function), but I want to do this with the toggle button, I tried various means by using Page_Load() in  databinding and checkchanged events but in vain. How can I correct the code></p>
  
  <p>Also I want to resize my background according to the resolution of the user. How can I do so? I surfed the net and tried to do many things with a stylesheet but in vain. Please Help.</p>
  
  <p>The Codes are given below from Vidual Studio 9.</p>
  
  <p><strong>Default.aspx :</strong></p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;
  &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Confidentially for 'You'&lt;/title&gt;
       &lt;link id="Link1" rel="Stylesheet" href="StyleSheet.css" type="text/css" runat="server" /&gt;
  &lt;/head&gt;
  &lt;body background="eternal_hearts-normal.jpg" text="white"&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
              &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
          &lt;/asp:ScriptManager&gt;
      &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
       &lt;ContentTemplate&gt; 
      &lt;p align="center" runat="server" id="p1"&gt;
          &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
  
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;br /&gt;Default Line&lt;/p&gt;
              &lt;p align="center" id="p2"&gt;
                  &lt;asp:Image ID="Image1" runat="server" EnableViewState="False" /&gt;
                  &lt;asp:CheckBox ID="CheckBox1" runat="server" 
                      oncheckedchanged="Page_Load" ondatabinding="Page_Load" /&gt;
  
                  &lt;cc1:ToggleButtonExtender ID="CheckBox1_ToggleButtonExtender" runat="server" 
                      Enabled="True" TargetControlID="CheckBox1" ImageWidth="19" 
                      ImageHeight="19" UncheckedImageUrl="ToggleButton_Unchecked.gif" 
                      CheckedImageUrl="ToggleButton_Checked.gif" ondatabinding="Page_Load"&gt;
                  &lt;/cc1:ToggleButtonExtender&gt;
  
                  &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /&gt;
                  &lt;asp:ImageButton ID="ImageButton1" runat="server" Height="23px" 
                      onclick="ImageButton1_Click" Width="30px" 
                      ImageUrl="~/ToggleButton_Unchecked.gif" /&gt;
                  &amp;nbsp;&lt;/p&gt;
       &lt;/ContentTemplate&gt; 
      &lt;/asp:UpdatePanel&gt;
      &lt;/div&gt;
  
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Default.aspx.cs :</strong></p>
  
  <pre><code>using System;
  using System.Configuration;
  using System.Data;
  using System.Linq;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.HtmlControls;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Xml.Linq;
  using System.Threading;
  
  public partial class _Default : System.Web.UI.Page 
  {
      static int flag = 0;
      protected void Page_Load(object sender, EventArgs e)
      {
          if (flag == 1)
          {
              f();
              p1.InnerHtml = "Line 1";
          }
          else if (flag == 2)
          {
              f();
              p1.InnerHtml = "Line 2";
          }
          else if (flag == 3)
          {
              f();
              p1.InnerHtml = "Line 3";
          }
          flag++;
      }
      protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
      {
          Page_Load(null, EventArgs.Empty);
      }
      protected void Button1_Click(object sender, EventArgs e)
      {
          //if (flag == 0)
          //{
          //    flag++;
          //    p1.InnerHtml = "Line 1";
          //}
          //else if (flag == 1)
          //{
          //    flag++;
          //    p1.InnerHtml = "Line 2";
          //}
          //else if (flag == 2)
          //{
          //    flag++;
          //    p1.InnerHtml = "Line 3";
          //}
  
      }
  
      protected void f()
      {
          ImageButton1.ImageUrl = "ToggleButton_Unchecked.gif";
      }
      protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
      {
  
      }
  }
  </code></pre>
  
  <p><strong>Stylesheet :</strong></p>
  
  <pre class="lang-css prettyprint-override"><code>img#background 
  {
      min-width: 800px;
      width: 100%;
      height: auto;
      position: absolute;
      top: 0;
      left: 0;
      z-index: -1;
  }
  
  div.back
  {
      overflow: hidden;
      left: 0;
      top: 0;
      position: absolute;
      z-index: -9999;
  }
  
  body
  {
      text-align: center;
      left: 50pt;
      right: 50pt;
      font-family: 'Bookman Old Style';
      position: absolute;
      z-index: auto;
      width : 100%;
      height : 100%;
  }
  </code></pre>