Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nicolas 5 posts 25 karma points
    Jul 01, 2011 @ 10:54
    Nicolas
    0

    Ajax Controls

    Hi all,

    I'm stuck down here for a couple of days trying to figure out what the hell between Umbraco and Ajax. Basically, I'm currently using a usercontrols as Macro to generate a Gridview to the frontend. This GridView run fine, including manually managed Sorting, Paging and Select.

     

    As I surround it by a Updatepanel tag, adding a Scriptmanager just before, the macro still render correctly.

    <form runat="server" id="form1" >
      <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
        <ContentTemplate>
          <asp:GridView ID="GridView1" [...] >
    <Columns>
              <asp:BoundField [...] />
    [...]
              <asp:BoundField [...] />       </Columns>
          </asp:GridView>
    <asp:Button ID="Insert" runat="server" [...] CommandName="Insert" />
          <asp:Button ID="Update" runat="server" [...] CommandName="Update" />
          <asp:Button ID="Delete" runat="server" [...] CommandName="Delete" />
        </ContentTemplate>
      </asp:UpdatePanel>
    </form>

     

    Problem is that the _dopostback client side events does not fire anymore. I still can see the html links on mouse over but nothing else append anymore.

    javascript:__doPostBack('ctl00$ctl00$ctl00$ctl00$ContentPlaceHolderDefault$body$primary_content$ctl00$MyPage_3$MyGridView','Sort$FirstColumn')

     

    Also, I can not access to my Ajax controls from the code behind.

    Editing:      \App_Code\myCodeBehind_ascx.cs

    [...]
    using
    System.Web.UI;
    [...]
    ScriptManager mySM;
    UpdatePanel myUP;
    [...]

    Errors:

    The type or namespace name 'ScriptManager' could not be found (are you missing a using directive or an assembly reference?)
    The type or namespace name 'UpdatePanel' could not be found (are you missing a using directive or an assembly reference?)

     

    Editing again:      \App_Code\myCodeBehind_ascx.cs

    System.Web.UI.ScriptManager mySM;
    System.Web.UI.UpdatePanel myUP;

    Errors:

    The type or namespace name 'ScriptManager' 
    does not exist in the namespace 'System.Web.UI' (are you missing an 
    assembly reference?)
    The type or namespace name 'UpdatePanel' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?)

     

    I assume my Ajax extensions are correctly installed (backend Ajax stuffs run correctly). Here is part of my web.config:

    [...]
    <!-- ASPNETAJAX  -->

    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
    </sectionGroup>
    </sectionGroup>
    </sectionGroup>
    [...]
    <!-- ASPNETAJAX -->
    <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add tagPrefix="umbraco" namespace="umbraco.presentation.templateControls" assembly="umbraco" />
    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </controls>
    [...]
    <!-- ASPNETAJAX -->
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    [...]
    <compilation defaultLanguage="c#" debug="false" batch="false">
    <assemblies>
    <!-- ASPNETAJAX -->
        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </assemblies>
    </compilation>

     

    I'm building this project using Umbraco Azure Deployment Accelerator as base. My Umbraco instance is currently running on Windows Azure.

    • Umbraco v 4.5.2 (Assembly version: 1.0.3891.20719)
    • Azure SDK Version:1.2.10512.1409
    • Azure OS Version: WA-GUEST-OS-1.9_201011-01


    I know that there is other ways to handle Ajax in Umbraco: /Base, AjaxToolKit and probably more but my need is really basic so I'm wondering if I could just use an UpdatePanel to achieve.

    Thanks guys for any help on that point.

  • Nicolas 5 posts 25 karma points
    Jul 01, 2011 @ 11:24
    Nicolas
    0

    Just FYI:

    • .Net Version: 2.0.50727.4206
    • Web Server Version: Microsoft-IIS/7.0
  • Nicolas 5 posts 25 karma points
    Jul 01, 2011 @ 12:51
    Nicolas
    0

    And, as far as I can see, when I click on my Select/Sorting/Paging link or button with the updatepanel implemented, I can see that the Javascript _dopostback(...) is launched but not all the data is sent back to the server. When ASP.NET validates the viewstate, it fails.Eaqch time, I've got this event logged:

    Error Administrator (none) 01/07/2011 10:44:41 At /my-aspx-page (Referred by: http://mysite/my-aspx-page): System.Web.UI.ViewStateException: Invalid viewstate. Client IP: 11.22.33.44 Port: 1234 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 ViewState: 9+etDx0eL2+fdhOwgH+pnyi/pVauPgp3kZ[...]62RkQFyPYyBMi5Wwxy6UtjUoFLBmz0L+eilpD9Wqq...
  • Nicolas 5 posts 25 karma points
    Jul 01, 2011 @ 17:26
    Nicolas
    0

    The simple answer is to place a copy of the files described below in the application’s "bin" folder of Umbraco.

    • System.Web.Extensions.Design.dll
    • System.Web.Extensions.dll

    There are available here:  C:\WINDOWS\Assembly. 

    Unfortunately, you can’t see the individual files using Windows Explorer. However, the files can be viewed using the command prompt. It is a bit of a messy process, but it is possible to use the Command Prompt to extract the files. 

    You can then import the namespace in your codebehind and play with Ajax controls:

        using System.Web.Extensions;
        private ScriptManager mySM = new ScriptManager();

    Hope it will help one...

     

Please Sign in or register to post replies

Write your reply to:

Draft