Posted By: m1keread | Feb 16th, 2008 @ 2:40 PM
page 1 of 1
Comments: 7 | Views: 1075
m1keread
m1keread
Bored of Captions

Hi guys,

I just cannot get AJAX Update panel to perform as I expect.

I am in VS2008, a new ASP.NET website,

add a ScriptManager
add an UpdatePanel
Inside Update Panel, add a button

In the buttons OnClick() event, add the following

Button1.Text = DateTime.Now.ToString();

Problem:

Every time I press the button, I get a full postback!!!
I have tried lots of examples from the web and get full postbacks on all of them.  I am using the built in webserver with VS2008

Update:  Just noticed also, that for a micro second I get the "Done but with Errors on Page" flash in the status bar.  I can also run demo AJAX pages from websites without fault.

Can anyone point me in a direction to investigate ?  Full code to webform below.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %>

<%@ Register assembly="System.Web.Extensions, Version=1.0.61025.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">

<div>

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

</div>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

</ContentTemplate>

</asp:UpdatePanel>

</form>

</body>

</html>


Thanks

Mike

You're referencing ASP.NET AJAX 1.0 with your Register directive.  Is the site you've developed targeting 3.5?

Are you referencing ASP.NET AJAX HttpHandlers and HttpModules in your Web.config? It takes more than just adding a reference to the server-side ASP.NET AJAX controls to enable ASP.NET AJAX on a Web site.

At a minimum, you need to reference the ScriptResource handler at least so that ASP.NET will know how to get the ASP.NET AJAX scripts from the System.Web.Extensions assembly.

Reference: Configuring ASP.NET AJAX [ASP.NET AJAX Documentation]

IIS 6.0-style Web.config (add to configuration/system.web)

<httpHandlers>
  <remove verb="*" path="*.asmx"/>
  <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

IIS 7.0-style Web.config (add to configuration)

<system.webServer>
  <handlers>
    <remove name="WebServiceHandlerFactory-Integrated"/>
    <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </handlers>
  <modules>
    <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </modules>
  <validation validateIntegratedModeConfiguration="false"/>
</system.webServer>

There's a download with ASP.NET AJAX 1.0 project templates for Visual Studio 2008 so you don't have to mess with the Web.config.

Microsoft ASP.NET 2.0 AJAX Templates for Visual Studio 2008

Have fun with it!

page 1 of 1
Comments: 7 | Views: 1075
Microsoft Communities