Click here to Skip to main content
15,879,326 members
Articles / Web Development / HTML

Build a Google IG like AJAX Start Page in 7 days using ASP.NET AJAX and .NET 3.0

Rate me:
Please Sign up or sign in to vote.
4.80/5 (325 votes)
10 Mar 2010CPOL38 min read 1.8M   7.8K   1.1K  
Build a Start Page similar to Google IG in 7 nights using ASP.NET AJAX, .NET 3.0, LINQ, DLinq, and XLinq.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Theme="Default" EnableSessionState="False"  %>
<%@ Register Src="Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="Footer.ascx" TagName="Footer" TagPrefix="uc2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="CustomDragDrop" Namespace="CustomDragDrop" TagPrefix="cdd" %>
<%@ Register Src="WidgetContainer.ascx" TagName="WidgetContainer" TagPrefix="widget" %>
<!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>It's not real Google IG!</title>
    <script type="text/javascript">
    function WidgetDropped( container, item, position )
    {
        var instanceId = parseInt(item.getAttribute("InstanceId"));
        var columnNo = parseInt(container.getAttribute("columnNo"));
        var row = position;
        
        //alert( container.id + ": " + item.id + ": " + position + ": " +  );
        WidgetService.MoveWidgetInstance( instanceId, columnNo, row );
    }
    function $hide(id)
    {
        document.getElementById(id).style.display="none";
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
            
        <!-- Render header first so that user can start typing search criteria while the huge runtime and other scripts download -->
        <uc1:Header ID="Header1" runat="server" />

        <!-- TODO: Show update progress -->
        <div id="body">
        
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">        
            <Services>
                <asp:ServiceReference InlineScript="true" Path="WidgetService.asmx" />                
            </Services>
        </asp:ScriptManager>
        
        <asp:UpdatePanel ID="AddContentUpdatePanel" runat="server" UpdateMode="conditional">
        <ContentTemplate>
            <asp:LinkButton CssClass="add_stuff_toggle" ID="ShowAddContentPanel" runat="server" Text="Add stuff �" OnClick="ShowAddContentPanel_Click"/>
            <asp:LinkButton CssClass="add_stuff_toggle" ID="HideAddContentPanel" runat="server" Text="Hide Stuff" OnClick="HideAddContentPanel_Click" Visible="false" />
            
            <asp:Panel ID="AddContentPanel" runat="Server" CssClass="widget_showcase" Visible="false">
            <div style="float:left"><b>Click on any of the item to add it to your page.</b></div>
            <div style="float:right"><asp:LinkButton ID="WidgetListPreviousLinkButton" runat="server" Visible="false" Text="&lt; Previous" OnClick="WidgetListPreviousLinkButton_Click" /> | <asp:LinkButton ID="WidgetListNextButton" runat="server" Visible="false" Text="Next &gt;" OnClick="WidgetListNextButton_Click" /></div>
            <br /><br />
                <asp:DataList ID="WidgetDataList" runat="server" RepeatDirection="Vertical" RepeatColumns="5" RepeatLayout="Table" CellPadding="3" CellSpacing="3" EnableViewState="False" ShowFooter="False" ShowHeader="False">
                    <ItemTemplate><asp:Image ID="Icon" ImageUrl='<%# Eval("Icon") %>' ImageAlign="AbsMiddle" runat="server" />&nbsp;<asp:LinkButton CommandArgument='<%# Eval("ID") %>' CommandName="AddWidget" ID="AddWidget" runat="server"><%# Eval("Name") %></asp:LinkButton></ItemTemplate>
                </asp:DataList>
            </asp:Panel>            
            <ajaxToolkit:AnimationExtender ID="AddContentPanelAnimation" runat="server" TargetControlID="AddContentPanel">
                <Animations>
                    <OnLoad>
                        <FadeIn minimumOpacity=".2" />
                    </OnLoad>
                </Animations>
            </ajaxToolkit:AnimationExtender>
        </ContentTemplate>
        </asp:UpdatePanel>
        
        <asp:UpdatePanel ID="TabUpdatePanel" runat="server" UpdateMode="conditional">
        <ContentTemplate>
            <div id="tabs">
            <ul class="tabs" runat="server" id="tabList"><li class="tab inactivetab"><asp:LinkButton id="Page1Tab" runat="server" Text="Page 1"></asp:LinkButton></li><li class="tab activetab"><asp:LinkButton id="Page2Tab" runat="server" Text="Page 2"></asp:LinkButton></li>
            </ul>            
            </div>        
        </ContentTemplate>
        </asp:UpdatePanel>
        
        <asp:UpdatePanel ID="WidgetViewUpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <table width="98%" cellspacing="10" border="0" align="center" class="table_fixed" height="100%">
            <tbody>
                <tr>
                    <td class="column">
                        <asp:Panel ID="LeftPanel" runat="server"  class="widget_holder" columnNo="0">
                            <div id="DropCue1" class="widget_dropcue">
                            </div>
                        </asp:Panel>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td class="column">
                        <asp:Panel ID="MiddlePanel" runat="server" class="widget_holder" columnNo="1">
                            <div id="DropCue2" class="widget_dropcue">
                            </div>
                        </asp:Panel>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td class="column">
                        <asp:Panel ID="RightPanel" runat="server" class="widget_holder" columnNo="2">
                            <div id="DropCue3" class="widget_dropcue">
                            </div>
                        </asp:Panel>
                    </td>
                    <td>
                        &nbsp;</td>
                </tr>
            </tbody>
        </table>
        
        <cdd:CustomDragDropExtender ID="CustomDragDropExtender1" runat="server" TargetControlID="LeftPanel"
            DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="DropCue1"
            DropCallbackFunction="WidgetDropped" />
        <cdd:CustomDragDropExtender ID="CustomDragDropExtender2" runat="server" TargetControlID="MiddlePanel"
            DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="DropCue2" 
            DropCallbackFunction="WidgetDropped" />
        <cdd:CustomDragDropExtender ID="CustomDragDropExtender3" runat="server" TargetControlID="RightPanel"
            DragItemClass="widget" DragItemHandleClass="widget_header" DropCueID="DropCue3" 
            DropCallbackFunction="WidgetDropped" />
        
        </ContentTemplate>
        </asp:UpdatePanel>        
        
        </div>
        <!--<textarea id="TraceConsole" rows="10" cols="80"></textarea>-->
        <hr />
        
        
        <uc2:Footer runat="server"></uc2:Footer>
    </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
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

Comments and Discussions