Ziad is a father of 2 cute girls,Senior Software Developer, lives in Kuwait and enjoys technology in general...
Search This Blog
Tuesday, November 11, 2014
Thursday, November 6, 2014
Class not registered exception - SharePoint 2013
Hi All,
We got below error when trying to use SPSecurity.RunWithElevatedPrivileges in console application
Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
We got below error when trying to use SPSecurity.RunWithElevatedPrivileges in console application
Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
The code is shown below:
using Microsoft.SharePoint; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SampleComnsoleApp { class Program { static void Main(string[] args) { bool quiet = false; SPSecurity.RunWithElevatedPrivileges(delegate() { (new Program()).Run(quiet); }); } private void Run(bool quiet) { } } }
Resolution:
The console application is running under 32 bit processor. Just change it to 64 bit.
To do this:
The console application is running under 32 bit processor. Just change it to 64 bit.
To do this:
- Right click on Console Application
- Select Properties
- Under Build Tab, change Platform Target to x64
- Rerun the application and hopefully the error should go away now !
Tuesday, October 28, 2014
Accept only numbers in a APS.NET Textbox using JavaScript
Client side validations become very important when submitting data on a web page. Here is a practical scenario. We have an input box and it must accept only numbers, and it should not allow other characters as input. We will validate the contents of the input box at the client side before calling a post back event.
Client side validations become very important when submitting data on a web page. Here is a practical scenario. We have an input box and it must accept only numbers, and it should not allow other characters as input. We will validate the contents of the input box at the client side before calling a post back event.
The Markup and Script
<html>
<head></head>
<body>
<div>
Enter only Numbers: <asp:TextBox ID="txtNumbers" value="" runat="server"
onkeypress="javascript:return isNumber (event)" ></asp:TextBox>
</div>
</body>
<script>
// WRITE THE VALIDATION SCRIPT IN THE HEAD TAG.
function isNumber(evt) {
var iKeyCode = (evt.which) ? evt.which : evt.keyCode
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
return false;
return true;
}
</script>
</html>
Overview
In the head tag we have the JavaScript block with a function named as “isNumber()”, which takes a Keyboard event as parameter. The parameter will be checked against “Ascii KeyCodes”.
Ascci stands for “American Standard Code for Information Interchange”.
Check KeyCode
Individual key events will be checked for each character entered in the textbox.
The code “var iKeyCode = (evt.which) ? evt.which : evt.keyCode” works like a conditional “if…else”. This piece of code can also be written in this way.
The code “var iKeyCode = (evt.which) ? evt.which : evt.keyCode” works like a conditional “if…else”. This piece of code can also be written in this way.
Var iKeyCode;
If (evt.which)
iKeyCode = evt.which;
Else
iKeyCode = evt.keyCode; // KEYWORDS ARE CASE SENSITIVE.
The value in iKeyCode will be checked against a range of Ascii codes to make sure it’s a number (numeric value). The function will return “true” or “false” based on the entered value. No value will be displayed on the “textbox” control if the condition is returned as “false”.
The input control in the body tag accepts the user entered values, which calls the JavaScript function “isNumber()” on its “onkeypress” event. So every time a user tries to enter a value other than numbers, the field won’t accept the value.
Thanks
Ziad Sowan
Monday, October 27, 2014
Implement Ajax Control Toolkit with SharePoint 2013
Hi All
After Painstaking research, I managed to make AjaxControlToolkit and especially Update Panel working with SharePoint 2013 using the following steps:
1- Download Ajax Control Toolkit 4.5 from
http://ajaxcontroltoolkit.codeplex.com/releases/view/112805
3- Register AjaxControlToolkit and AjaxMin namespaces in SharePoint package Designer.
- To Open package Designer see below image
- To register AjaxControlToolkit and AjaxMin as safe controls see below two images
- Register AjaxMin dll as above step.
<add assembly="AjaxControlToolkit, Version=4.5.7.1005, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />
- First add below line in head section of the master page
<%@ Register assembly="AjaxControlToolkit, Version=4.5.7.1005, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" namespace="AjaxControlToolkit" tagprefix="asp" %>
- Second Remove default script manger then add below ToolkitScriptManager line, make sure its placed inside form section of master page
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true">
</asp:ToolkitScriptManager>
Finally it should look like below :
<SharePoint:SharePointForm onsubmit="if (typeof(_spFormOnSubmitWrapper) != 'undefined') {return _spFormOnSubmitWrapper();} else {return true;}" runat="server">
<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">
<WebPartPages:SPWebPartManager runat="Server"/>
</SharePoint:AjaxDelta>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true">
</asp:ToolkitScriptManager>
<%@ Register Assembly="AjaxControlToolkit, Version=4.5.7.1005, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
Happy AJAX
Ziad Sowan
Tuesday, February 11, 2014
Your Guide to Building a Windows Phone 8 App
To get started:
- Register as a Windows Phone Developer
- Develop and Test Your Application
- Assemble the Prerequisites for Certification
- Submit Your Application for Certification
- Link to Your Application in the Windows Phone Marketplace Catalog
- Updating Your Application in the Windows Phone Marketplace
SharePoint 2010 , Application Development Exam
Last week i passed TS: Microsoft SharePoint 2010, Application Development Exam with score 800/1000.
Current i am preparing for SharePoint 2013 , Core Solution Exam.
Current i am preparing for SharePoint 2013 , Core Solution Exam.
Subscribe to:
Posts (Atom)


