This project is read-only.

Need in N2 Ajax using samples?

Jan 8, 2009 at 4:43 PM
Is there any ways to use Ajax?
I saw at web.config that there is Ajax handlers, how could i use it?
And may be N2 has it's own ajax mechanisms?
Jan 8, 2009 at 8:07 PM
You should probably use standard updatepanels or e.g. WCF.

N2 uses a custom scheme with the http handler you saw (to play better with jquery and avoid dependencies). To use it you can register a "sub-handler":

            N2.Context.Current.Resolve<N2.Web.AjaxRequestDispatcher>().AddHandler(myHandler);

This isn't really documented but you could look at existing usages if you want to use it.

Jan 8, 2009 at 11:05 PM
Standard updatePanels doesn't want work, i can't understand...
That's the page code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxTest.aspx.cs" Inherits="N2.Addons.DMSPrograms.Plugins.AjaxTest" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
        
       
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
            <ContentTemplate>
         
                <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />            
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                
            </ContentTemplate>
        </asp:UpdatePanel>

        <asp:UpdateProgress DynamicLayout="true" ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server">
            <ProgressTemplate>Loading...</ProgressTemplate>
        </asp:UpdateProgress>        
        
        <div><%= DateTime.Now.ToString() %></div>
    </form>
</body>
</html>

        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(1000);
            Label1.Text = DateTime.Now.ToString();
        }

On button click page is updating as it should, but by standard postback (all page is restarting not partially).
Help.
P.S.: May be this situation linked with web.config file, but I use one from N2 package...