Click here to Skip to main content
15,895,656 members
Articles / Web Development / HTML

ASP.NET AJAX: State or no State?

Rate me:
Please Sign up or sign in to vote.
4.47/5 (13 votes)
2 Jan 200710 min read 75.9K   386   56  
An article covering the two different design paths we can take when using the ASP.NET AJAX framework
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MultipleControls.aspx.cs" Inherits="State_MultipleControls" %>

<!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 id="Head1" runat="server">
    <title>UpdatePanel and Multiple Controls</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:ScriptManager 
            ID="sm" 
            runat="server" />
            
        <asp:UpdatePanel 
            ID="upGv" 
            runat="server">
            <ContentTemplate>
                <asp:GridView 
                    ID="gvPeople" 
                    runat="server" 
                    AllowPaging="True" 
                    AllowSorting="True"
                    AutoGenerateColumns="False" 
                    DataKeyNames="personid" 
                    DataSourceID="odsPeople" 
                    Width="400px">
                    <Columns>
                        <asp:CommandField 
                            ShowEditButton="True" />
                        <asp:CommandField 
                            ShowDeleteButton="true" />
                        <asp:BoundField 
                            DataField="firstname" 
                            HeaderText="First Name" 
                            SortExpression="firstname" />
                        <asp:BoundField 
                            DataField="lastname" 
                            HeaderText="Last Name" 
                            SortExpression="lastname" />
                    </Columns>
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>
        
        <asp:UpdateProgress 
            ID="upProgGv" 
            runat="server" 
            AssociatedUpdatePanelID="upGv">
            <ProgressTemplate>
                <p>Please wait Loading...</p>
            </ProgressTemplate>
        </asp:UpdateProgress>
        
        <asp:UpdatePanel 
            ID="upFv" 
            runat="server">
            <ContentTemplate>
                <asp:FormView 
                    ID="fvPerson" 
                    runat="server" 
                    DataSourceID="odsPeople" 
                    DefaultMode="Insert">
                    <InsertItemTemplate>
                        <asp:TextBox
                            ID="txtFirstName" 
                            Text='<%# Bind("firstname") %>' 
                            runat="server" />
                        <asp:TextBox 
                            ID="txtLastName"
                            Text='<%# Bind("lastname") %>' 
                            runat="server" />
                        <asp:LinkButton 
                            ID="lbInsert" 
                            CommandName="Insert" 
                            Text="Add Person" 
                            runat="server" />
                        <asp:LinkButton 
                            ID="lbCancel" 
                            CommandName="Cancel" 
                            Text="Cancel" 
                            runat="server" />
                    </InsertItemTemplate>
                </asp:FormView>
            </ContentTemplate>
        </asp:UpdatePanel>
        
        <asp:UpdateProgress 
            ID="upProgFv" 
            runat="server" 
            AssociatedUpdatePanelID="upFv">
            <ProgressTemplate>
                <p>Adding Person Please wait...</p>
            </ProgressTemplate>
        </asp:UpdateProgress>
        
        <asp:ObjectDataSource 
            ID="odsPeople" 
            runat="server" 
            SelectMethod="GetPeople" 
            InsertMethod="Insert" 
            UpdateMethod="Update" 
            DeleteMethod="Delete" 
            OldValuesParameterFormatString="original_{0}" 
            TypeName="PeopleTableAdapters.PeopleTableAdapter">
            <InsertParameters>
                <asp:Parameter 
                    Name="firstname" 
                    Type="String" />
                <asp:Parameter 
                    Name="lastname" 
                    Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter 
                    Name="personid" 
                    Type="Int32" />
                <asp:Parameter 
                    Name="firstname" 
                    Type="String" />
                <asp:Parameter 
                    Name="lastname" 
                    Type="String" />
            </UpdateParameters>
            <DeleteParameters>
                <asp:Parameter 
                    Name="original_personid" 
                    Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
    
    </div>
    </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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
Europe Europe
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions