PDA

View Full Version : ASP.NET Ajax ControlToolkit



rakams
05-13-2009, 09:43 AM
Hi everybody,

I posted yesterday within an old thread so that I think it's better to open a new one.

I have a problem using ASP.NET Ajax ControlKit and any help will be welcome.

Problem :
I have a button extend with a confirmButtonExtender.
When I click the button I get the following error :
"InvalidOperationException: Extender controls may not be registered before PreRender"

Configuration
System.Web

<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Spring.Web.Script.Services.ScriptHandlerFactory, Spring.Web.Extensions"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewMo dule, Spring.Data.NHibernate20"/>
</httpModules>


System.WebServer :


<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</modules>

<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Spring.Web.Script.Services.ScriptHandlerFactory, Spring.Web.Extensions"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.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=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>



I use a masterpage :


<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Stock.master.cs" Inherits="Stock.Net.Stock" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!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">
<link href="~/CSS/default.css" type="text/css" rel="stylesheet"/>
<spring:Head id="Head1" runat="server">
<title>Page sans titre</title>
<asp:ContentPlaceHolder id="head" runat="server" />
</spring:Head>
</head>
<body>
<div id="blocPrincipal">
<form id="bodyForm" runat="server">
<div id="blocNavigation">Navigation</div>
<div id="blocContenu">
<asp:ContentPlaceHolder ID="bodyContentPlaceHolder" runat="server">

</asp:ContentPlaceHolder>
</div>
<div id="blocPiedDePage">Copyright</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</form>
</div>

</body>
</html>

And in the aspx file I have :



<%@ Page Language="C#" MasterPageFile="~/Stock.Master" AutoEventWireup="true" CodeBehind="FactureFournisseurEdit.aspx.cs" Inherits="Stock.Net.Achat.FactureFournisseurEdit" Title="Page sans titre" %>
...
<asp:Button ID="annulerModificationsButton" runat="server" Text="Annuler Modifications"/>
<ajaxToolkit:ConfirmButtonExtender ID="annulerModificationsButton_ConfirmButtonExtender"
runat="server" ConfirmText="Confirmer ?"
TargetControlID="annulerModificationsButton">
</ajaxToolkit:ConfirmButtonExtender>

I think it is enough clear. And I thank you for advance for your helps.

rakams
05-13-2009, 06:08 PM
I'm still working with this issue and I have some extra informations. Maybe someone have ideas ?

When I disable any datacontrols binding ou updating on both button controls events (see coloured text in code below), the ajax control works but only after the first postback.


protected override void OnInit(EventArgs e)
{

this.enregistrerButton.Click += new EventHandler(enregistrerButton_Click);
this.annulerModificationsButton.Click += new EventHandler(annulerModificationsButton_Click);
this.enteteFactureFormView.ItemUpdating += new FormViewUpdateEventHandler(enteteFactureFormView_I temUpdating);
this.detailsFactureGridView.RowInserting += new RealWorld.Grids.GridViewInsertEventHandler(details FactureGridView_RowInserting);
this.detailsFactureGridView.RowUpdating += new GridViewUpdateEventHandler(detailsFactureGridView_ RowUpdating);
this.detailsFactureGridView.RowDeleting += new GridViewDeleteEventHandler(detailsFactureGridView_ RowDeleting);
this.detailsFactureGridView.RowCommand += new GridViewCommandEventHandler(detailsFactureGridView _RowCommand);


this.factureObjectDataSource.ObjectCreating += new ObjectDataSourceObjectEventHandler(factureObjectDa taSource_ObjectCreating);
this.factureObjectDataSource.Selected += new ObjectDataSourceStatusEventHandler(factureObjectDa taSource_Selected);
this.factureObjectDataSource.Updating += new ObjectDataSourceMethodEventHandler(factureObjectDa taSource_Updating);
this.deviseObjectDataSource.ObjectCreating += new ObjectDataSourceObjectEventHandler(deviseObjectDat aSource_ObjectCreating);
this.lignesFactureObjectDataSource.ObjectCreating += new ObjectDataSourceObjectEventHandler(lignesFactureOb jectDataSource_ObjectCreating);

base.OnInit(e);
}



The event handlers contains instructions updating or databinding datacontrols.
When disabling those instructions, Ajax control works but only after a first postback.


void enregistrerButton_Click(object sender, EventArgs e)
{
//detailsFactureGridView.Save();
//enteteFactureFormView.UpdateItem(true);

documentDao.SaveOrUpdate(facture);

}

void annulerModificationsButton_Click(object sender, EventArgs e)
{
InitializeModel();
//DataBind();
}


And of course, when I enable these instructions, I still have the same error : "InvalidOperationException: Extender controls may not be registered before PreRender"

Thanks.