Update of /cvsroot/magicajax/magicajax/Examples/ExampleSite (.NET 2.0 only)/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19561/magicajax/Examples/ExampleSite (.NET 2.0 only)/examples Added Files: Basic.aspx CallbackTimer.aspx DataGrid.aspx FormElementsTest.aspx MasterDetail.aspx WebParts.aspx Wizard.aspx Log Message: Added example site for .NET 2.0 --- NEW FILE: FormElementsTest.aspx --- <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void btnClearAll_Click(object sender, EventArgs e) { this.AspTextBox.Text = null; this.HtmlTextBox.Value = null; this.AspMultilineTextBox.Text = null; this.AspPasswordTextBox.Text = null; this.HtmlTextArea.Value = null; this.AspCheckBox.Checked = false; this.AspRadioButton.Checked = false; this.AspDropDownList.SelectedIndex = -1; this.AspListBox.SelectedIndex = -1; this.AspMultipleListBox.SelectedIndex = -1; this.AspCheckBoxList.SelectedIndex = -1; this.AspRadioButtonList.SelectedIndex = -1; } protected void btnSetAll_Click(object sender, EventArgs e) { this.AspTextBox.Text = "hello world"; this.HtmlTextBox.Value = "hello world"; this.AspMultilineTextBox.Text = "hello world"; //this.AspPasswordTextBox.Text = "secret"; //note:setting of password fields not possible this.HtmlTextArea.Value = "hello world"; this.AspCheckBox.Checked = true; this.AspRadioButton.Checked = true; this.AspDropDownList.SelectedIndex = 2; this.AspListBox.SelectedIndex = 2; this.AspMultipleListBox.SelectedIndex = -1; this.AspMultipleListBox.Items[1].Selected = true; this.AspMultipleListBox.Items[2].Selected = true; this.AspCheckBoxList.SelectedIndex = -1; this.AspCheckBoxList.Items[1].Selected = true; this.AspCheckBoxList.Items[2].Selected = true; this.AspRadioButtonList.SelectedIndex = 2; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <ajax:ajaxpanel ID="Ajaxpanel1" runat="server"> <asp:Button ID="btnClearAll" runat="server" Text="Clear all" OnClick="btnClearAll_Click" /> <asp:Button ID="btnSetAll" runat="server" Text="Set all" OnClick="btnSetAll_Click" /> <asp:Button runat="server" Text="Callback" /> <br /> <table> <tr> <td>asp:textbox</td> <td><asp:TextBox ID="AspTextBox" runat="server" /></td> </tr> <tr> <td>html:textbox</td> <td><input id="HtmlTextBox" runat="server" /></td> </tr> <tr> <td>asp:textbox(multiline)</td> <td><asp:TextBox ID="AspMultilineTextBox" TextMode="MultiLine" runat="server" /></td> </tr> <tr> <td>asp:textbox(password)</td> <td><asp:TextBox ID="AspPasswordTextBox" TextMode="Password" runat="server" /></td> </tr> <tr> <td>html:textarea</td> <td><textarea cols="20" rows="2" id="HtmlTextArea" runat="server"></textarea></td> </tr> <tr> <td>asp:checkbox</td> <td><asp:CheckBox ID="AspCheckBox" runat="server" /></td> </tr> <tr> <td>asp:radiobutton</td> <td><asp:RadioButton ID="AspRadioButton" runat="server" /></td> </tr> <tr> <td>asp:dropdownlist</td> <td><asp:DropDownList ID="AspDropDownList" runat="server"><asp:ListItem Value="1" /><asp:ListItem Value="2" /><asp:ListItem Value="3" /></asp:DropDownList></td> </tr> <tr> <td>asp:listbox</td> <td><asp:ListBox ID="AspListBox" runat="server"><asp:ListItem Value="1" /><asp:ListItem Value="2" /><asp:ListItem Value="3" /></asp:ListBox></td> </tr> <tr> <td>asp:listbox(multiple)</td> <td><asp:ListBox SelectionMode="Multiple" ID="AspMultipleListBox" runat="server"><asp:ListItem Value="1" /><asp:ListItem Value="2" /><asp:ListItem Value="3" /></asp:ListBox></td> </tr> <tr> <td>asp:checkboxlist</td> <td><asp:CheckBoxList ID="AspCheckBoxList" runat="server"><asp:ListItem Value="1" /><asp:ListItem Value="2" /><asp:ListItem Value="3" /></asp:CheckBoxList></td> </tr> <tr> <td>asp:radiobuttonlist</td> <td><asp:RadioButtonList ID="AspRadioButtonList" runat="server"><asp:ListItem Value="1" /><asp:ListItem Value="2" /><asp:ListItem Value="3" /></asp:RadioButtonList></td> </tr> </table> </ajax:ajaxpanel> </form> </body> </html> --- NEW FILE: Wizard.aspx --- <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" %> <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <ajax:ajaxpanel ID="Ajaxpanel1" runat="server"> <fieldset> <legend>ASP.NET 2.0 Wizard control (with validator)</legend> <i>An example of an ASP.NET 2.0 Wizard control using MagicAjax.<br />Entering your name in the first step is mandatory (using a RequiredFieldValidator).</i><br /><br /> <asp:Wizard ID="Wizard1" CellPadding="7" HeaderText="Example Wizard" SideBarStyle-VerticalAlign="Middle" runat="server" ActiveStepIndex="0" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderWidth="1px" Font-Names="Verdana" SideBarStyle-Width="100px" NavigationStyle-Width="300px" OnFinishButtonClick="Wizard1_FinishButtonClick"> <StepStyle ForeColor="#333333" /> <SideBarStyle BackColor="#507CD1" /> <NavigationButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" ForeColor="#284E98" /> <WizardSteps> <asp:WizardStep runat="server" Title="Step 1"> <asp:Label ID="Label1" runat="server" Text="Enter your name"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" /><br /> <asp:RequiredFieldValidator runat="server" Display="Static" ControlToValidate="TextBox1" ErrorMessage="Please enter your name" /> </asp:WizardStep> <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 2"> <asp:CheckBox ID="CheckBox1" Checked="true" runat="server" Text="I like MagicAjax" /> </asp:WizardStep> <asp:WizardStep runat="server" StepType="Finish" Title="Overview"> <asp:Label runat="server" ID="overview" /> </asp:WizardStep> </WizardSteps> <SideBarButtonStyle BackColor="#507CD1" Font-Names="Verdana" ForeColor="White" /> <HeaderStyle BackColor="#284E98" BorderColor="#EFF3FB" BorderStyle="Solid" BorderWidth="2px" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" /> </asp:Wizard> <asp:Label runat="server" id="lblFinished" Text="Wizard is Finished!" Visible="false" BackColor="Khaki" /> </fieldset> </ajax:ajaxpanel> </asp:Content> <script runat="server"> private void Page_Load(object sender, EventArgs e) { if (IsPostBack) { overview.Text = string.Format("Hi {0}, {1} like MagicAjax.<br />Now click 'Finish'.", TextBox1.Text, CheckBox1.Checked ? "good to hear you" : "sorry to hear you don't"); } } protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e) { Wizard1.Visible = false; lblFinished.Visible = true; } </script> --- NEW FILE: CallbackTimer.aspx --- <%@ Page language="C#" MasterPageFile="~/MasterPage.master" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <ajax:ajaxpanel ID="Ajaxpanel1" runat="server"> <fieldset> <legend>Windows Processes (list is updated every 10 seconds using Callback Timer)</legend> <i>This example demonstrates the use of the MagicAjax CallbackTimer. <br />For this example we've set the Callback timer in the Page_Load event (hint: click 'View Source' at the bottom of this page to see the complete source of this aspx file).</i><br /><br /> <div style="overflow:auto;height:400px;width:325px"> <asp:DataGrid AutoGenerateColumns="false" AllowSorting="True" OnSortCommand="grid_SortCommand" runat="server" ID="DataGrid1" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="5" GridLines="Horizontal" > <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" Mode="NumericPages" /> <AlternatingItemStyle BackColor="#F7F7F7" /> <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <Columns> <asp:BoundColumn DataField="ProcessName" SortExpression="ProcessName" HeaderText="Image Name" /> <asp:BoundColumn DataField="PhysicalMemory" SortExpression="PhysicalMemory" HeaderText="Mem Usage" DataFormatString="{0:###,###,###} K" /> <asp:BoundColumn DataField="HandleCount" SortExpression="HandleCount" HeaderText="Handles" DataFormatString="{0:###,###}" /> </Columns> </asp:DataGrid> </div> </fieldset> </ajax:ajaxpanel> </asp:Content> <script language="C#" runat="server"> private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // For automatic CallBack every 10 seconds. MagicAjax.AjaxCallHelper.SetAjaxCallTimerInterval(10000); } ShowProcesses(); } private void ShowProcesses() { System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses(); System.Data.DataTable dt = new System.Data.DataTable("Processes"); dt.Columns.Add("ProcessName"); dt.Columns.Add("PhysicalMemory", typeof(Int64)); dt.Columns.Add("HandleCount", typeof(Int32)); foreach (System.Diagnostics.Process process in processes) { dt.Rows.Add(new object[] {process.ProcessName, process.WorkingSet64 /1000, process.HandleCount }); } System.Data.DataView dv = dt.DefaultView; //sort data dv.Sort = SortExpression; //bind data DataGrid1.DataSource = dv; DataGrid1.DataBind(); } /// <summary> /// SortExpression of the grid (stored in ViewState!) /// </summary> private string SortExpression { get { if (ViewState["_grid_SortExpression"] != null) { return (string)ViewState["_grid_SortExpression"]; } else { return "PhysicalMemory desc"; //default } } set { ViewState["_grid_SortExpression"] = value; } } private void grid_SortCommand(object source, DataGridSortCommandEventArgs e) { string[] currentSort = SortExpression.Split(' '); if (currentSort[0] == e.SortExpression) { SortExpression = string.Format("{0} {1}", e.SortExpression, currentSort[1] == "desc" ? "asc" : "desc"); } else { SortExpression = e.SortExpression + " asc"; } //refill datagrid ShowProcesses(); } </script> --- NEW FILE: Basic.aspx --- <%@ Page language="C#" MasterPageFile="~/MasterPage.master" %> <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <ajax:ajaxpanel ID="Ajaxpanel1" runat="server"> <fieldset> <legend>Simple button showing server time</legend> <i>The button makes a callback to the server and shows the server's date and time in a asp:Label tag.</i><br /><br /> <asp:Button runat="server" ID="ShowTime" Text="Show server's date & time" OnClick="ShowTime_Click" CausesValidation="false" /> <asp:Label runat="server" ID="lblShowTime" BackColor="Blue" ForeColor="White" /> </fieldset> <fieldset> <legend>Master/detail dropdown lists</legend> <i>An example of two connected dropdown lists (aka master-detail) without having to write any javascript client code. Note: to see the aspx source, click the 'View Source' link at the bottom of this page.</i><br /><br /> Please pick a car: <asp:DropDownList id="brand" runat="server" AutoPostBack="true" OnSelectedIndexChanged="brand_SelectedIndexChanged"> <asp:ListItem>- Select car brand -</asp:ListItem> </asp:DropDownList> <asp:DropDownList id="model" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="model_SelectedIndexChanged" /><br /><br /> <asp:Button id="select" runat="server" CausesValidation="false" Text="Select Car" Enabled="false" OnClick="select_Click" /> <asp:Label id="lblSelectedCar" runat="server" /> </fieldset> <fieldset> <legend>Textbox with a server-side validator</legend> <i>Demonstrate the use of server-side validators with MagixAjax. Works for all browsers ;)</i><br /><br /> Enter username: <asp:TextBox runat="server" ID="username" /> <asp:Button ID="username_submit" runat="server" Text="Submit" /> <asp:RequiredFieldValidator ID="username_check" runat="server" ControlToValidate="username" EnableClientScript="false" ErrorMessage="Please enter username." /> </fieldset> </ajax:ajaxpanel> <fieldset> <legend>Regular (Non-Ajax) Postback button</legend> <i>The 'Regular PostBack' button is used to demonstrate that the ViewState of the page is persisted between AJAX callbacks.</i><br /><br /> <asp:Button ID="Button1" runat="server" Text="Regular Postback" CausesValidation="false" /> </fieldset> <ajax:ajaxpanel ID="Ajaxpanel2" runat="server"> <fieldset> <legend>Button invoking a Response.Redirect()</legend> <i>This button calls the server side Response.Redirect() method to navigate to another page.</i><br /><br /> <asp:Button runat="server" CausesValidation="false" Text="Go to DataGrid example" OnClick="Redirect_Click" /> </fieldset> </ajax:ajaxpanel> </asp:Content> <script language="C#" runat="server"> private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //fill the car brands brand.Items.Add("VW"); brand.Items.Add("Mercedes"); brand.Items.Add("Citroen"); } } protected void ShowTime_Click(object sender, EventArgs e) { lblShowTime.Text = DateTime.Now.ToString(); } protected void brand_SelectedIndexChanged(object sender, EventArgs e) { model.Items.Clear(); model.Items.Add(new ListItem("- Select car model -", "")); model.Visible = true; select.Enabled = false; lblSelectedCar.Text = null; switch (brand.SelectedValue) { case "VW": model.Items.Add("Golf"); model.Items.Add("Passat"); model.Items.Add("Beetle"); model.Items.Add("Phaeton"); break; case "Mercedes": model.Items.Add("S Class"); model.Items.Add("E Class"); model.Items.Add("A Class"); model.Items.Add("M Class"); break; case "Citroen": model.Items.Add("C3 Pluriel"); model.Items.Add("C5 Break"); model.Items.Add("C8"); model.Items.Add("Berlingo"); break; default: model.Visible = false; break; } } protected void model_SelectedIndexChanged(object sender, EventArgs e) { select.Enabled = model.SelectedIndex != 0; lblSelectedCar.Text = null; } protected void select_Click(object sender, EventArgs e) { lblSelectedCar.Text = "You have picked the " + brand.SelectedValue + " " + model.SelectedValue; } protected void Redirect_Click(object sender, EventArgs e) { Response.Redirect("DataGrid.aspx"); } </script> --- NEW FILE: WebParts.aspx --- <%@ Page language="C#" MasterPageFile="~/MasterPage.master" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:WebPartManager ID="WebPartManager1" runat="server" Personalization-Enabled="true" /> <ajax:ajaxpanel ID="Ajaxpanel1" runat="server"> <fieldset> <legend>ASP.NET 2.0 WebParts demo <asp:LinkButton runat="server" id="Toggle" Text="[Switch to EditMode]" OnClick="Toggle_Click" /></legend> <i>Very cool demo of ASP.NET 2.0 WebParts running on MagicAjax.<br />Switch to EditMode and move/add/delete WebParts without a visible postback.<br /> Note: Your modifications are stored in Session, so will be lost when you leave this site.<br /> Note2: Dragging and dropping of WebParts is a ASP.NET 2.0 feature that is only supported for IE.</i><br /><br /> <table width="100%"><tr><td valign="top" width="30%"> <asp:WebPartZone runat="server" ID="WebPartZone1" Width="100%"> <PartTitleStyle CssClass="WebPartTitle" BackColor="LightBlue" /> <ZoneTemplate> <uc1:Logo ID="Logo1" runat="server" /> </ZoneTemplate> </asp:WebPartZone> </td><td valign="top" width="30%"> <asp:WebPartZone runat="server" ID="WebPartZone2" Width="100%"> <PartTitleStyle CssClass="WebPartTitle" BackColor="LightBlue" /> <ZoneTemplate> <uc1:Calendar ID="Calendar1" runat="server" /> </ZoneTemplate> </asp:WebPartZone> </td><td width="10%"> </td><td valign="top" width="30%"> <asp:CatalogZone ID="CatalogZone1" runat="server"> <HeaderStyle BackColor="Khaki" /> <FooterStyle BackColor="Khaki" /> <CloseVerb Visible="false" /> <HeaderCloseVerb Visible="false" /> <ZoneTemplate> <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" runat="server" Title="Catalog"> <WebPartsTemplate> <uc1:Logo ID="Logo1" runat="server" /> <uc1:Calendar ID="Calendar1" runat="server" /> </WebPartsTemplate> </asp:DeclarativeCatalogPart> </ZoneTemplate> </asp:CatalogZone> </td></tr></table> </fieldset> </ajax:ajaxpanel> </asp:Content> <script language="C#" runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Force setting of Session id (workaround for bug in MagicAjax) Session["dummy"] = "dummy"; // Authenticate user with dummy userName, so the WebPartManager will allow // switching to Editmode. FormsAuthentication.SetAuthCookie("dummy", false); } } protected void Toggle_Click(object sender, EventArgs e) { if (WebPartManager1.DisplayMode == WebPartManager.BrowseDisplayMode) { Toggle.Text = "[Switch to ViewMode]"; WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode; } else { Toggle.Text = "[Switch to EditMode]"; WebPartManager1.DisplayMode = WebPartManager.BrowseDisplayMode; } } </script> --- NEW FILE: MasterDetail.aspx --- (This appears to be a binary file; contents omitted.) --- NEW FILE: DataGrid.aspx --- <%@ Page language="C#" MasterPageFile="~/MasterPage.master" %> <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <ajax:ajaxpanel ID="Ajaxpanel1" runat="server"> <fieldset> <legend>Datagrid using MagicAjax (incl. sorting and selecting)</legend> <i>This is a very basic example of a datagrid that does sorting and selecting without a visible postback to the server.<br /> Try this: reduce the height of your browser window's, so you need to scroll down to see the grid. Notice that MagicAjax keeps the scroll-position after callbacks.</i><br /><br /> <asp:DataGrid Width="250px" id="grid" Runat="server" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4" AllowSorting="True" PageSize="3" OnSortCommand="grid_SortCommand"> <FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle> <SelectedItemStyle ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle> <ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle> <Columns> <asp:ButtonColumn Text="Select" CommandName="Select"></asp:ButtonColumn> </Columns> <PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC"></PagerStyle> </asp:DataGrid> </fieldset> </ajax:ajaxpanel> </asp:Content> <script language="C#" runat="server"> private void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //fill datagrid (example 2) FillGrid(); } } /// <summary> /// Creates a DataTable and binds to grid /// </summary> private void FillGrid() { //create data System.Data.DataTable dt = new System.Data.DataTable("Person"); dt.Columns.Add("Brand"); dt.Columns.Add("Model"); dt.Rows.Add(new string[] {"BMW", "X3"}); dt.Rows.Add(new string[] {"Citroen", "Berlingo"}); dt.Rows.Add(new string[] {"Fiat", "Punto"}); dt.Rows.Add(new string[] {"Mercedes", "E Class"}); dt.Rows.Add(new string[] {"Opel", "Zafira"}); dt.Rows.Add(new string[] {"Peugeot", "206"}); dt.Rows.Add(new string[] {"Volvo", "V70"}); dt.Rows.Add(new string[] {"VW", "Golf"}); System.Data.DataView dv = dt.DefaultView; //sort data dv.Sort = SortExpression; //bind data grid.DataSource = dv; grid.DataBind(); } /// <summary> /// SortExpression of the grid (stored in ViewState!) /// </summary> private string SortExpression { get { if (ViewState["_grid_SortExpression"] != null) { return (string)ViewState["_grid_SortExpression"]; } else { return "Brand asc"; //default } } set { ViewState["_grid_SortExpression"] = value; } } private void grid_SortCommand(object source, DataGridSortCommandEventArgs e) { string[] currentSort = SortExpression.Split(' '); if (currentSort[0] != e.SortExpression) { grid.SelectedIndex = -1; SortExpression = e.SortExpression + " asc"; } else { SortExpression = string.Format("{0} {1}", e.SortExpression, currentSort[1] == "desc" ? "asc" : "desc"); } //refill datagrid FillGrid(); } </script> |