<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PageCallback.aspx.cs" Inherits="PageCallback"  EnableViewState="false"%>
<%@Register Namespace="Westwind.Web.Controls" assembly="Westwind.AjaxToolkit" TagPrefix="ww" %>
<%@ Register Src="~/ShowCode.ascx" TagName="ShowCode" TagPrefix="uc1" %>
<html>
<head id="Head1" runat="server">
    <title>wwHoverWindow Method Callbacks</title>
    <link href="WestWind.css" rel="stylesheet" type="text/css" />
</head>
<body onload="document.getElementById('lstInvoices').onchange();">
    <form runat="Server" id="form1" method="post">
<script type="text/javascript">
// *** Just start the callback and we're done
function StartCallback(event)
{
    InvoiceDetailPanel.startCallback(event,'id=' +  $('lstInvoices').value,null,OnPageError);
}

// *** Start and set notification for a callback when result is returned
function StartCallbackWithNotification(event)
{
    // *** Optionally get notified when the result returns
    InvoiceDetailPanel.callbackHandler = InvoiceDetail_Callback;        
    InvoiceDetailPanel.startCallback(event,'id=' +  $('lstInvoices').value,null,OnPageError);
}
function InvoiceDetail_Callback(Result)
{
    var Panel = $('InvoiceDetailPanel');           
    
    // *** Reformat the returned data in some way
    Result = Result.replace("Invoice #","Order Receipt: ");    
    Panel.innerHTML = Result;
    
    // *** false: Don't update panel
    return false;
}
function OnPageError(Exception)
{
    alert("*** Callback error: " + Exception.message);
}
</script>
    <div>
        <h1> wwHoverPanel Page Callbacks</h1>
        <br />
        <a href="default.aspx"><span style="color: #00008b">Home</span></a> | <a href="PageCallback.aspx">
            Reset Page</a>
            
        <br /><br />
            
        <div style="margin-left: 15px">
        <span style="font-style:italic;font-size:x-small">Page generated at: <%= DateTime.Now %></span>
            <div style="padding:20px;padding-right:80px;padding-left:0px;">
            This simple example demonstrates how to specify content from an external url
            and load it into a static HTML panel which in effect updates the current page.            
            This can all be done throught the HoverPanel's properties plus one line of JavaScript
            to initiate the dynamic callback to retrieve the data.
            </div>
            
            <b>Select an invoice:</b><br />
            <asp:DropDownList ID="lstInvoices" runat="server" Width="400px"  
                              onchange="StartCallback()">
            </asp:DropDownList>
            <hr />
            
             <ww:wwhoverpanel id="InvoiceDetailPanel" runat="server" 
                          ScriptLocationType="WebResource"
                          ServerUrl="InvoiceAbstract.aspx" 
                          EventHandlerMode="ShowHtmlInPanel"                           
                          Height="350px" Width="550px"                            
             >
             </ww:wwhoverpanel>
            <br />
            <br />
        <hr />
        </div>
        
<div class="divError"></div>        
<script type="text/javascript">

</script>
        <blockquote>
            This example sets all properties via the control's properties on the server side
            but you can also drive the control from the client side. Bascially you 
            specify EventHandlerMode=&quot;<b>ShowHtmlInPanel</b>&quot; and a base (or complete) ServerUrl
            that you would like to hit to retrieve content.
            <br />   
            <br />         
            The client code here is hooked to the <em>onchange</em> even of the DropDownList and
            it simply starts the callback:<br />
            <br />
            <span style="font-family: Courier New">InvoiceDetailPanel.startCallback(event,'id='
                + document.getElementById('lstInvoices').value);"</span>
            <br />
         </blockquote>
            
            <hr />
            <uc1:showcode id="ShowSource" runat="server" codefile="~/PageCallback.aspx.cs"></uc1:showcode>
            <uc1:showcode id="ShowAspx" runat="server" codefile="~/PageCallback.aspx"
                text="Show ASPX"></uc1:showcode>

        
    </div>
    </form>
</body>
</html>
