incepand cu Service Pack 1 pentru AJAX.NET. Pentru aceasta insa trebuie urmati pasii:
- Downloadati si instalati
ASP.NET 2.0 AJAX Extensions 1.0 pe server-ul unde esta instalat SharePoint 2007 (daca SharePoint-ul s-a instalat intr-un webfarm, atunci ASP.NET Ajax Extensions trebuie instalat pe fiecare server); - Modificati web.config-ul
de la website-ul(urile) din SharePoint pentru care vreti sa activati Ajax (voi detalia
mai jos); - Adaugati ScriptManager-ul la nivel de master.page
Modificarea web.config-ului
Mai intai trebuie sa identificati website-ul din SharePoint pentru care doriti adaugarea
suportului pentru AJAX, retineti portul si deschideti web.config-ul din locatia
file:////[servername]/c$/Inetpub/wwwroot/wss/VirtualDirectories/[PortNumber]/web.config - daca accesati pe retea serverul unde este instalat MOSS 2007
sau
c:\Inetpub\wwwroot\wss\VirtualDirectories\[PortNumber]\web.config - daca accesati direct serverul unde este instalat MOSS 2007
si:
1. Adaugati un element nou <sectionGroup> in interiorul tag-ului <configSections>:
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
2. Adaugati tag-ul <controls> in interiorul <system.web>/<pages>:
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
3. Adaugati urmatoarele inregistrari in tag-ul <assemblies> din sectiunea
<compilation>:
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
4. Adaugati urmatoarele linii la sfarsitul sectiunii <httpHandlers>:
<httpHandlers>
<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>
5. Adaugati urmatoarea linie la sfarsitul sectiunii <httpModules>:
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
6. Inregistrati toate controalele din System.Web.Extensions ca SafeControls in
interiorul sectiunii <SharePoint>/<SafeControls>:
<SafeControls>
<SafeControl Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />
</SafeControls>
7. In final adaugati urmatoarea sectiune la sfarsitul web.config-ului, chiar inainte de tag-ul </configuration>:
<system.web.extensions>
<scripting>
<webServices>
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "truefalse"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
-->
&nbs
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</modules>
<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>
</system.webServer>
Adaugati ScriptManager-ul
E bine stiut ca pentru a putea folosi UpdatePanel-ul si celelalte controale din ASP.NET Ajax
Extension trebuie ca la inceputul paginii sa fie adaugat un tag <asp:ScriptManager...>, iar acesta nu poate exista in pagina decat maxim odata. Varianta cea mai simpla e sa adaugam ScriptManager-ul in interiorul webpart-ului nostru, insa solutia nu merge... Ce se intampla daca in aceeasi pagina adaugam mai multe instante ale webpart-ului nostru? Bineinteles ca se vor crea mai multe instante ale ScriptManager-ului si aplicatia va crapa.
Exista insa doua solutii care elimina aceasta problema:
1. Modificam master page-ul din SharePoint si adaugam tag-ul
<asp:ScriptManager...> la inceputul acestuia. Acesta poate fi deschis fie cu
SharePoint Designer 2007, sau chiar cu notepad-ul, din view-ul
http://[moss_server]/_catalogs/masterpage/Forms/AllItems.aspx iar tag-ul
ScriptManager trebuie adaugat imediat dupa <form>.
2. O varianta mult mai flexibila si la indemana tuturor o reprezinta SmartPart-ul... Pentru aceasta trebuie downloadat si instalat Return of SmartPart (gasiti un document Word in interiorul arhivei care va explica cum se instaleaza si cum se foloseste). Acest modul contine un webpart numit AJAXSmartPart si care poate fi folosit pentru controalele care folosesc
AJAX.
Aruncand un ochi cu reflector-ul lui Roeder in assembly-ul SmartPart-ului, la tip-ul AJAXSmartPart, vedem ca la initializarea controlului se obtine instanta curenta din pagina de ScriptManager, iar daca nu exista se creeaza si se adauga. Asa ca folositi-l cu incredere ;-)
8 comentarii:
ai tradus de aici http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3. impresile tale persoanale
http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3
Ti-a copiat exemplu si a tradus ce ai scris tu Mike Ammerlaan.
@Mag: intr-un fel ai dreptate... m-am inspirat din ce-a scris Mike in blogul sau.
Dar...
1. Toate modificarile care trebuie sa le faci in web.config (ce-i cu bg gri) le poti face singur, fara sa fii geniu sau sa le copii de la mine sau Mike:
- deschizi un Visual Studio 2005/2008
- File -> New -> Project si alegi ASP.NET Ajax-Enabled Web Application
- in web.config ai sa gasesti toate configurarile specifice ASP.NET Ajax-ului (la primele mele incercari nici nu citisem blog-ul lui Mike, exact asa am facut).
- un singur lucru trebuie sa-l faci in plus fata de ce se genereaza automat... sa declari toate tipurile din System.Web.Extensions ca SafeControls.
2. Adaugarea unui :lt;asp:ScriptManager ...> in master.page-ul din SharePoint... este singurul lucru nou care l-am invatat din postul respectiv de la Mike. Si crede-ma ca nu-l folosesc din motive de deployment.
3. Mike nu a scris nimic despre SmartPart (de fapt ReturnOfSmartPart)... si poate era bine sa insist mai mult pentru ca este solutia cea mai convenabila din punct de vedere al usurintei dezvoltarii de user controls pentru MOSS.
hei , stai asa. nu am zis ca sa te ofensez. asa este cum ai descris. si daca stiam ca e direct public ca inainte sa fi aprobat nu comentam "negativ".
SmartPart (de fapt ReturnOfSmartPart)... aici e descrisa. punctul 3.
http://weblogs.asp.net/jan/archive/2007/02/26/using-the-ajax-control-toolkit-in-sharepoint.aspx
E moderat, dar am dat approve la ambele... mi se pare ok sa fiu comentat si negativ si pozitiv, asta-i viata. In plus daca esti comentat negativ, mai si inveti. Deci no offense, ba chiar merci pentru comentarii:)
Cat despre SmartPart, uite aici chiar de la sursa http://www.codeplex.com/smartpart
Radu,
am o eroare care nu stiu sa o rezolv:
pe webpartul:
SmartPart
Error: unable to load ~\/UserControls\timel.ascx
Details: Unknown server tag 'asp:ScriptManager'
Pe SmartPart with AJAX
Error: unable to load ~\/UserControls\datal.ascx
Details: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.
Poti sa ma ajuti?
marius.mag@hotmail.com
Scuze ca am vazut cu mare intarziere comment-ul tau Marius.
Daca pur si simplu copii assembly-ul AjaxControlToolkit.dll in bin-ul din SharePoint, nu-ti merge?
In plus trebuie sa adaugi in web.config:
<SafeControls>
...
<SafeControl Assembly="AjaxControlToolkit, Version=1.0.11119.20010, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TypeName="*" Safe="True" />
....
</SafeControls>
La fel si cu System.Web.Extensions.dll, copie-l in /bin si adauga in web.config:
<SafeControls>
...
<SafeControl Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />
....
</SafeControls>
Am rezolvat. Era de la versiunea de AjaxControlToolkit in aeu am copiat exact cum se descrie in post ,dar pe calc avem alta versiune de AjaxControlToolkit in Windows\assembly. Am verificat de versiune de AjaxControlToolkit am , apoi am trecut versiunea corecta in web.config. despre linia asta era vorba add assembly="AjaxControlToolkit, Version=3.0.11119.25533, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"
mersi mersi
Trimiteți un comentariu