Tuesday, November 27, 2012

Convert your VMW drives VMDK to Hyper-V drives VHD

After installing Windows 8 and using Hyper-V I searched for a tool to convert my VMW disks to be used on Hyper-V. This tool is amazing and it just take few minutes to convert a disk with Windows2008R2/SQLServer/SharePoint2010/VisualStudio2010


Tuesday, November 20, 2012

Special offer for Exam 70-480: Developing in HTML5 with JavaScript and CSS3

There is a special offer from Microsoft as a jump start and voucher code for free exam for 70-480: Developing in HTML5 with JavaScript and CSS3, it is one of the Windows 8 development series.

Get it from there:

I passed this exam two weeks ago, "al 7amd lellah"

Get Web Part Properties for a page with PowerShell script

It happens when you have a problem with a webpart in one of your SharePoint environments in need to debug to see what are the properties of this webpart, this PowerShell script can help:

#Add-PSSnapin Microsoft.SharePoint.PowerShell

$SiteUrl = "http://www.yoursite.com"
$pageURL = "Pages/default.aspx"

$site = New-Object Microsoft.SharePoint.SPSite($SiteUrl)
$psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
$web = Get-SPWeb $SiteUrl
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

#List all the web parts
$wpm.WebParts | ft

#Get the details of the first web part
$wp = $wpm.WebParts[0]

SharePoint 2013 on Windows 2012 Server - Admin Intro

Just installed SharePoint 2013 Server on Windows 2012 Server and SQL 2012 Server inside Hyper-V machine on Windows 8 :)

Just wanted to share with you the screen as this will be my first blog post on SharePoint 2013, and just to show you something useful, this is the performance screen for my server till the moment:

My machine is Dell Latitude E6520 with 8 GB RAM

Wednesday, October 10, 2012

Active File in Solution Explorer - Visual Studio 2010 & Windows 8

Today I Installed Visual Studio 2010 on Windows 8 beside Visual Studio 2012, and what I noticed is that the active file - the one I am editing now - is not highlighted in the Solution Explorer, and this was really annoying as moving between files dose not showing me which file in the solution hierarchicy I am editing. And I though it is a bug in the beginning but I figured out that it is an option:

From "Tools" go to "Options" then "Projects and Solutions",  and under "General" change"Track active item in Solution Explorer" to checked.

I don't know why there is an option like this, why a user may need to edit a file and that file is not highlighted in the solution explorer

Thursday, May 24, 2012

Convert Anonymous Type into key/value Array

The answer in this link is very simple and great:


var a = new { data1 = "test1", data2 = "sam", data3 = "bob" };
var type = a.GetType();
var props = type.GetProperties();
var pairs = props.Select(x => x.Name + "=" + x.GetValue(a, null)).ToArray();
var result = string.Join("&", pairs);

Wednesday, March 21, 2012

Custom ViewState in MVC

Just in case anyone want to build his own ViewState here is an example:

The model is serialized JSON (you can write JavaScript to read any information even if it is not rendered in a separate control) and then deserialized.

For security (if your model contains information that should not displayed in the HTML source, you can encrypt it then decrypt it with the post back), also compression will be helpful for smaller response/request. (I think this is why MVC is better in performance, because NO ViewState :) )

Also in the code after getting the data from the ViewState, you can compare it with the data retrieved from the model to know which field is updated, you can then call a method accordingly (the same as TextBox1_Changed(...., ....) in ASP.NET forms), this can be done as well from JavaScript by injecting in the hidden field using jQuery whenever the value of any control is updated.

In the form add a hidden field that will hold the viewstate, plus all your other controls.

You can also add in the ViewState a bool value indicating the IsPostBack, and use this value in the form or the code.