I have discovered a weird problem in Sharepoint 2010 and many of developers have discovered that too. To reproduce the problem follow the following steps:
1. Create new list of any type (Calendar, custom,...etc).
2. browse the list.
3. Click on Add new Item.
4. In the pop up, click on maximize before the page finishes loading (once the maximize button appear). (A).
5. once maximized or once the pop up appears, click on close to close the pop up dialog. (B)
Expected:
for A: the pop up should be maximized.
for B: the pop up should be closed and returns to the list view.
Actual:
For A: Invalid Argument javascript error occurs in SP.UI.RTE.js.
For B: Invalid Argument javascript error occurs in SP.UI.Dialog.js.
I have tried the above scenarios in multiple servers and i can reproduce the the error in all cases. i have tried to resolve the problem but i cannot find any straightforward one. However, i discovered that after the javascript errors appear, the pop up behaves normally so, i decided to try handling that error by writing a custom javascript to handle the error. After that, the javascript errors disappeared and everything is now working very well.
To handle that error, just write a custom javascript function to handle the error using the following code:
//START DIRTY WORKAROUND TO HANDLE THE JS ERROR WHEN CLICKING ADD NEW ITEM OR EDIT AND MAXIMIZE BEFORE WINDOW FINISHS LOADING
//ALSO HANDLES WHEN CLOSING THE POPUP BEFORE FINISHING, IT GIVES JS ERROR.
function noErrorMessages(err, url) {
// HANDLE MAX THE POPUP ERROR
if (err.search(/invalid argument/gi) >= 0 && url.search(/sp.ui.rte/gi) >= 0) {
return true;
}
// HANDLES CLOSING THE POPUP
else if (err.search(/or not an object/gi) >= 0 && url.search(/sp.ui.dialog/gi) >= 0) {
return true;
}
return false;
}
window.onerror = noErrorMessages;
//END DIRTY WORKAROUND
The above javascript code hides the above errors only and behaves normally for the other javascript errors. (use browser default behavior). By adding the above javascript code to the master page or to the page that shows the adding new item or editing existing item, the javascript errors will disappear and everything will behave normally.
It's all about Microsoft .net framework and how to use Microsoft technologies in your application.
Thursday, December 2, 2010
Tuesday, September 7, 2010
Configuring WCF for Multi Addresses
If you have a web site that has two address, for example: http://IP:PORT/ and http://www.YourSiteHere.com, and if you have a WCF that you need it to work in both URLs, then the configuration of the WCF will be different in that case. To achieve that add the following elements under system.ServiceModel
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.YourSiteHere.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.YourSiteHere.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
Monday, May 24, 2010
Thursday, February 11, 2010
Fixing Ajax using WCF in Web.config and IIS 7.0
Sometimes when you call WCF from javascript (http://Site/Service.svc/js) or adding your WCF URL as service reference in the script manager, you find that the JS Proxy of the WCF returns 404 not found from the server. You can Check my previous post for more error details here: http://kholyos.blogspot.com/2010/02/how-to-solve-404-not-found-when-calling.html
You can fix this issue using alternative method, by modifying in the web.config of your application. Using the <handlers> tag under <system.webserver> can do the trick for you.
By adding the following Elements under <configuration><system.webserver><handlers> you can fix the issue:
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />
<add name="svc-ISAPI-2.0-64" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />
for more Information about handlers tag, you can follow this link to MSDN: http://msdn.microsoft.com/en-us/library/ms691481.aspx
That's it. And Enjoy :).
You can fix this issue using alternative method, by modifying in the web.config of your application. Using the <handlers> tag under <system.webserver> can do the trick for you.
By adding the following Elements under <configuration><system.webserver><handlers> you can fix the issue:
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />
<add name="svc-ISAPI-2.0-64" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />
for more Information about handlers tag, you can follow this link to MSDN: http://msdn.microsoft.com/en-us/library/ms691481.aspx
That's it. And Enjoy :).
Monday, February 8, 2010
How to Solve 404 Not Found When Calling WCF from Javascript using script manager
When you and Service reference in the script manager to point to .svc file, and then calling it from javascript, sometimes it gives you script error in the page that the service cannot be found. To solve this issue, follow these steps (Considering you have IIS 7.0):
- Make sure that .Net framework 3.0 or later is installed on the server. You can find it here.
- Register the service model to the IIS by doing the following:
- Open CMD.exe
- Navigate to: "C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation"
- Run "ServiceModelReg.exe -r"
- then, if you have x64 Windows, Navigate to: "C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation"
- then run: "ServiceModelReg.exe -r"
- Open IIS. You can use Run->inetmgr.
- Click on the site that hosts the .svc file, and browse the Features view in the IIS. Then, open the Handler Mappings.
- In the right Panel (Actions), Choose Add Script Map.
- A window will appear to add new script map, and fill the following parameters:
- Click Add Script Map again if you have x64 Windows and use the following parameters:
- Then browse the Service using your internet browser : http://yourURL/...../YourService.svc/js, if you can see the scripts generated by Microsoft Ajax then you are done. Otherwise, you should allow anonymouse in your web site.
Request Path : *.svc
Executable : %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
Name: svc-ISAPI-2.0
Request Path : *.svc
Executable : %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll
Name: svc-ISAPI-2.0-64
Subscribe to:
Posts (Atom)