Click here to Skip to main content
15,886,199 members
Articles / Web Development / HTML

Dirty Panel Extender (ASP.NET AJAX)

Rate me:
Please Sign up or sign in to vote.
4.61/5 (30 votes)
5 Sep 2007CPOL4 min read 331.4K   1.8K   94  
A dirty panel extender implementation with ASP.NET AJAX control toolkit.
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Simple.aspx.cs" Inherits="DirtyPanel._Simple" %>

<%@ Register Assembly="DirtyPanelExtender" Namespace="DirtyPanelExtender" TagPrefix="dp" %>
<!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>Dirty Panel Demo</title>
</head>
<body>
 <form id="form1" runat="server">
  <asp:ScriptManager ID="ScriptManager1" runat="server" />
  <div>
   Dirty Panel
  </div>
  <p>
   Write something, then <a href="Default.aspx">click here</a> to go back.
  </p>
  <dp:DirtyPanelExtender ID="demoPanelExtender" runat="server" TargetControlID="demoPanel"
   OnLeaveMessage="There's still unsaved data on the page!" />
  <asp:UpdatePanel ID="demoPanel" runat="server">
   <ContentTemplate>
    <p>
     <asp:TextBox ID="demoTextBoxSimple" runat="server" />
    </p>
    <p>
     <asp:DropDownList ID="demoDropDown" runat="server">
      <asp:ListItem Selected="true" Text="first" />
      <asp:ListItem Text="second" />
      <asp:ListItem Text="third" />
     </asp:DropDownList>
     <asp:Button ID="demoDropDownAdd" runat="server" OnClick="demoDropDownAdd_Click" Text="Add" />
    </p>
    <p>
     <asp:RadioButtonList ID="demoRadio" runat="server">
      <asp:ListItem Selected="true" Text="first" />
      <asp:ListItem Text="second" />
      <asp:ListItem Text="third" />
     </asp:RadioButtonList>
     <asp:Button ID="demoRadioAdd" runat="server" OnClick="demoRadioAdd_Click" Text="Add" />
     (doesn't work)
    </p>
    <p>
     <asp:ListBox ID="demoListBox" runat="server">
      <asp:ListItem Selected="true" Text="first" />
      <asp:ListItem Text="second" />
      <asp:ListItem Text="third" />
     </asp:ListBox>
     <asp:Button ID="demoListBoxAdd" runat="server" OnClick="demoListBoxAdd_Click" Text="Add" />
    </p>
    <p>
     <asp:ListBox ID="demoListBoxMultiple" SelectionMode="Multiple" runat="server">
      <asp:ListItem Selected="true" Text="first" />
      <asp:ListItem Text="second" />
      <asp:ListItem Selected="true" Text="third" />
     </asp:ListBox>
     <asp:Button ID="demoListBoxMultipleAdd" runat="server" OnClick="demoListBoxMultipleAdd_Click"
      Text="Add" />
    </p>
    <p>
     Enter Text:
     <br />
     <asp:TextBox ID="demoTextBox" runat="server" TextMode="MultiLine" Rows="5" />
    </p>
    <p>
     <asp:CheckBox ID="demoCheckBox" runat="server" Checked="true" Text="Checkbox" />
    </p>
    <p>
     <asp:Button ID="demoButton" runat="server" Text="Save" OnClick="save_Click" />
     <asp:Label ID="lastsaved" runat="server" Text="not saved" />
    </p>
   </ContentTemplate>
  </asp:UpdatePanel>
 </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
dB.
Team Leader Application Security Inc., www.appsecinc.com
United States United States
Daniel Doubrovkine has been in software engineering for twelve years and is currently development manager at Application Security Inc. in New York City. He has been involved in many software ventures, including Xo3 and Vestris Inc, was a development lead at Microsoft Corp. in Redmond, and director of Engineering at Visible Path Corp. in New York City. Daniel also builds and runs a foodie website, http://www.foodcandy.com.

Comments and Discussions