Need help Toggle Button in AJAx in ASP.net

as1238

New Member
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>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.The Codes are given below from Vidual Studio 9.Default.aspx :\[code\]<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Confidentially for 'You'</title> <link id="Link1" rel="Stylesheet" href="http://stackoverflow.com/questions/11704588/StyleSheet.css" type="text/css" runat="server" /></head><body background="eternal_hearts-normal.jpg" text="white"> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <p align="center" runat="server" id="p1"> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />Default Line</p> <p align="center" id="p2"> <asp:Image ID="Image1" runat="server" EnableViewState="False" /> <asp:CheckBox ID="CheckBox1" runat="server" oncheckedchanged="Page_Load" ondatabinding="Page_Load" /> <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"> </cc1:ToggleButtonExtender> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> <asp:ImageButton ID="ImageButton1" runat="server" Height="23px" onclick="ImageButton1_Click" Width="30px" ImageUrl="~/ToggleButton_Unchecked.gif" /> &nbsp;</p> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>\[/code\]Default.aspx.cs :\[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\]Stylesheet :\[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\]
 
Back
Top