Friday 12 October 2012

Enter Key for Login Form

$('.login-box-form input').keypress(function (e) {
                   if (e.which == 13) {
                       __doPostBack('ctl00$ctl50$lnklogin', '');
                   }
               });

Monday 1 October 2012

how to copy a dll file from gac?

    start Command Prompt

    write "cd :\Windows\assembly\GAC_MSIL\Microsoft.SharePoint.IdentityModel\14.0.0.0__71e9bce111e9429c\"

    write "copy Microsoft.SharePoint.IdentityModel.dll c:\"

    now you can access the dll freely (e.g. copy to TFS, open with reflector or any other action)

Saturday 15 September 2012

Jquery Everytime function

$(document).everyTime(5000, function () {

UpdateNews();

});

http://jquery.offput.ca/timers/

or

window.setInterval(function() {
    UpdateNews();
}, 50000);

Friday 14 September 2012

Reset form values with Javascript

$(this).closest('.form-container-table').find('input,textarea').val('')

Example:  <a onclick="$(this).closest('.form-container-table').find('input,textarea').val('')" href="javascript:;">RESET</a>

Thursday 13 September 2012

Fast search connector setup

PS C:\> .\securefastsearchconnector.ps1 -certPath .\FASTSearchCert.pfx -ssaName
"FASTContent" -userName "domain\MOSSDEV"

Thursday 6 September 2012

Problem with httpContext.RewritePath on IIS 7

<configuration>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
</system.webServer></configuration>

http://stackoverflow.com/questions/4976893/problem-with-httpcontext-rewritepath-on-iis-7

Tuesday 4 September 2012

How to remove illegal characters from a string?

public static string RemoveIllegalCharacters(string stringValue)
       {
           string pattern = @"[^\w\s\-\+]";
           string replacement = " ";
           string noResultText = "noresult";

           Regex regEx = new Regex(pattern);
           string sanitized = regEx.Replace(stringValue, replacement);
           if (!string.IsNullOrEmpty(sanitized.Trim()))
               return sanitized;
           else
               return noResultText;
       }

Wednesday 29 August 2012

Clear Control Values

void ResetControl(Control control)
        { 
            foreach (Control ctrl in control.Controls)
            {

                if (ctrl is TextBox)
                {
                    (ctrl as TextBox).Value = string.Empty;
                }

}
        }

The term 'Enable-SPSessionStateService' is not recognized as the name of a cmdlet, function…

Add-PSSnapin Microsoft.Sharepoint.Powershell

Enable-SPSessionStateService -DefaultProvision

Saturday 18 August 2012

Pass parameter to Web service method

var ddlAddressSelectedValue = $("#<%=ddlAddress.ClientID %>").val();
$("#<%=AddressHidden.ClientID %>").val(ddlAddressSelectedValue);

data = "{addressId:'" + ddlAddressSelectedValue + "'}";

Friday 3 August 2012

Multiple content in FAST Server

In Microsoft FAST Search Server 2010 for SharePoint

Clear-FASTSearchContentCollection sitecollectionName

Example:  Clear-FASTSearchContentCollection sp

FAST Search for SharePoint PowerShell Error: Failed to communicate with the WCF service

Run as Different User (hold down shift while right clicking on the icon), to run PowerShell with my fastuser account.

Tuesday 31 July 2012

Creating and using an XML based Sitemap in SharePoint

http://www.sharepointninja.com/Blog/Lists/Posts/Post.aspx?ID=56

http://meandmysharepoint.blogspot.com/2011/11/customising-sharepoint-global.html

The crawler could not communicate with the server. Check that the server is available and that the firewall access is configured correctly

Change site collection welcome page!

Example: http://mysharepointurl/default.aspx

The type 'xxx.Class' is defined in an assembly that is not referenced. You must add a reference to assembly 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ffa52fbb92e79dbd'

 

Web.Config

<assemblies>

<add assembly="xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ffa52fbb92e79dbd'" />

</assemblies>

How to delete a workspace in TFS Server

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>

WORKSPACENAME= computer name,

USERNAME = UserName

tf workspace /delete WORKSPACENAME;USERNAME

Cannot find Autofac container

Global.asax

<%@ Assembly Name="Microsoft.SharePoint"%>
<%@ Assembly Name="Autofac.Integration.Web, Version=2.6.1.841, Culture=neutral, PublicKeyToken=17863af14b0044da"%>
<%@ Import Namespace="Autofac.Integration.Web"  %>
<%@ Application Language="C#" Inherits="AutofacContainerProvider.SHttpApplication, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3c6f45e89aad3c3a" %>

Monday 30 July 2012

SharePoint Upgrade Check Status

stsadm.exe -o localupgradestatus

SharePoint Version Problems

You need to read.

http://www.sharepointdesignerstepbystep.com/blog/SitePages/SharePoint%20versions.aspx

Restore-SPSite : Your backup is from a different version of Microsoft SharePoi
t Foundation and cannot be restored to a server running the current version. T
e backup file should be restored to a server with version '4.1.11.0' or later.
At line:1 char:15
+ Restore-SPSite <<<<  -Identity http://yourserverurl -Path C:\deploy\
backup.bak
    + CategoryInfo          : InvalidData: (Microsoft.Share...dletRestoreSite:
   SPCmdletRestoreSite) [Restore-SPSite], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreS
   ite

[x] item them still need upgrade or cannot be upgraded

psconfig -cmd upgrade -inplace b2b -force -wait

SharePoint 2010 Backup and Restore site

Backup-SPSite -Identity http://myserver -Path "c:\backup\file.bak"

Restore-SPSite -Identity http://myserver -Path "c:\backup\file.bak"

Sunday 22 July 2012

How to get the value hidden control of user control in .aspx page

 

In .ascx file(UserControl1)

<script type="text/javascript">
    $(function () {
        $('.address-radio').change(
            function () {
                $('#<%=AddressHidden.ClientID %>').val($(this).val())
                            }
        )
    })
</script>

<asp:HiddenField ID="AddressHidden" runat="server" />

In aspx page

HiddenField hidden = (HiddenField)UserControl1.FindControl("HiddenField1");
        if (hidden != null)
        {
            string value = hidden.Value.ToString();
        }

http://forums.asp.net/t/1369427.aspx

Wednesday 27 June 2012

Deploying SharePoint Package with stsadm

 

path C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
stsadm -o retractsolution   -name InformationCenter.wsp -immediate -url http://sharepointSiteUrl

stsadm -o execadmsvcjobs

path C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
stsadm -o deletesolution   -name InformationCenter.wsp

path C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
stsadm -o addsolution -filename "c:\InformationCenter.wsp"
stsadm -o deploysolution -name InformationCenter.wsp -url http://sharepointSiteUrl -immediate -allowgacdeployment

stsadm -o execadmsvcjobs

Friday 22 June 2012

UpdatePanel initializeRequest and endRequest

$(document).ready(function() {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandle);
            Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequest);
            var postBackElement = "";
            function initializeRequest(sender, eventArgs) {
                postBackElement = eventArgs.get_postBackElement().id;
            }
           
            function endRequestHandle(sender, args) {
                if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack())
                    // Do something…                   
            }
        });

Tuesday 19 June 2012

asp.net tab doesn't show in iis

start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;^ IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;^ IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;^ IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;^ IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ManagementScriptingTools;^ IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;^ IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;^ IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;^ IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;^ WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;^ WCF-NonHTTP-Activation

Wednesday 6 June 2012

How to dynamically resize images

http://cmsnsoftware.blogspot.com/2011/09/how-to-dynamically-resize-images.html

Raw ActionLink linkText

 public static IHtmlString MyActionLink(
this HtmlHelper htmlHelper,
string linkText,
string action,
string controller,
object routeValues,
object htmlAttributes
)
{
var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext);
var anchor = new TagBuilder("a");
anchor.InnerHtml = linkText;
anchor.Attributes["href"] = urlHelper.Action(action, controller, routeValues);
anchor.MergeAttributes(new RouteValueDictionary(htmlAttributes));
return MvcHtmlString.Create(anchor.ToString());
}




http://stackoverflow.com/questions/6063467/raw-actionlink-linktext

Friday 1 June 2012

Adding Custom HTTP Headers to an ASP.NET MVC Response

http://blog.gregbrant.com/post/Adding-Custom-HTTP-Headers-to-an-ASPNET-MVC-Response.aspx

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new HttpHeaderAttribute("X-UA-Compatible", "IE=Edge,chrome=1"));
}



or



in web.config



<system.webServer>



<httpProtocol>


  <customHeaders>




    <add name="X-UA-Compatible" value="IE=Edge,chrome=1" />


    <remove name="X-Powered-By" />




  </customHeaders>


</httpProtocol>




</system.webServer>

Saturday 19 May 2012

Get Querystring Parameter

 public virtual T GetQueryString<T>(string name)
{
string queryParam = null;
if (Request.QueryString[name] != null)
queryParam = Request.QueryString[name];

if (!String.IsNullOrEmpty(queryParam))
return (T)TypeDescriptor.GetConverter(queryParam.GetType()).ConvertFrom(null, Thread.CurrentThread.CurrentCulture, queryParam);

return default(T);
}

Wednesday 16 May 2012

Read a property from Active Directory

public static string GetUserProperty(string user, string propertyName)
        {
            using (var context = new PrincipalContext(ContextType.Domain, “yourDomainName”)
            {
                UserPrincipal userPrincipal = new UserPrincipal(context);
                userPrincipal.SamAccountName = user;

                PrincipalSearcher principalSearcher = new PrincipalSearcher();
                principalSearcher.QueryFilter = userPrincipal;

                Principal searchResults = principalSearcher.FindOne();

                if (searchResults != null)
                {
                    return searchResults.GetProperty(propertyName);
                }
            }

            return string.Empty;
        }

Monday 14 May 2012

Dynamic Proxy Tutorial

http://kozmic.pl/dynamic-proxy-tutorial/

ASP.NET MVC 3 Aspect Oriented Programming with Castle Interceptors

http://cangencer.wordpress.com/2011/06/02/asp-net-mvc-3-aspect-oriented-programming-with-castle-interceptors/
http://blog.andreloker.de/post/2009/02/20/Simple-AOP-integrating-interceptors-into-Windsor.aspx

Turn off enclosing tags in CKEditor

ckeditor/config.js


CKEDITOR.editorConfig = function( config )
{
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_BR;
};

Friday 30 March 2012

LinkButton - Not firing click event in second time

http://theway2sharepoint.blogspot.com/2012/03/linkbutton-not-firing-click-event-in.html

 

<script type="text/javascript">

function setFormSubmitToFalse()
{
_spFormOnSubmitCalled = false;
return true;
}

</script>

<asp:LinkButton ID="btnDate" runat="server" HtmlEncode="false" CommandName="Download" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" Text='<%# Eval("Date")%>' OnClientClick="javascript:setFormSubmitToFalse();"></asp:LinkButton> 

Monday 12 March 2012

Get querysytring parameter with javascript

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

Reference:http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx

Tuesday 21 February 2012

Select LINQ extension method

collection.Select(item=> new { CityId = item.CityId });

Wednesday 15 February 2012

Powershell in Microsoft SharePoint 2007

Windows Powershell Setup for Windows Server 2003 x64 Edition:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=16000

Sample Powershell Script:

[System.Reflection.Assembly]::Load('Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c') | Out-Null
$site = new-object Microsoft.SharePoint.SPSite("http://sharepointsite")
$web = $site.OpenWeb()
$web
$web.AnonymousPermMask64 = "ViewListItems, ViewVersions, Open, ViewPages, UseClientIntegration, ViewFormPages"
$web.Dispose()
$site.Dispose()

 

Reference: http://blog.metrostarsystems.com/2011/04/20/leveraging-sharepoint-2007-through-windows-powershell/

Monday 13 February 2012

ASP.NET MVC: Adding active tag for html elements

 public static MvcHtmlString SelectedLink(this HtmlHelper helper, string linkText, string actionName, string controlName, string activeClassName, int id)
{
if (helper.ViewContext.RouteData.Values["action"].ToString() == actionName &&
helper.ViewContext.RouteData.Values["controller"].ToString() == controlName)
return helper.ActionLink(linkText, actionName, controlName, new { Class = activeClassName, Id = id });

return helper.ActionLink(linkText, actionName, controlName);
}
or 
 
        public static MvcHtmlString ActiveMenuItem(this HtmlHelper helper, string linkText, string actionName, string controllerName, int id)
{
TagBuilder li = new TagBuilder("li");

RouteData routedata = helper.ViewContext.RouteData;
string currentAction = routedata.GetRequiredString("action");
string currentController = routedata.GetRequiredString("controller");
int currentId = ConvertionHelper.GetConvertedValue<int>(routedata.GetRequiredString("id"));

if (string.Equals(currentAction, actionName, StringComparison.OrdinalIgnoreCase) &&
string.Equals(currentController, controllerName, StringComparison.OrdinalIgnoreCase) &&
int.Equals(currentId, id))
{
li.AddCssClass("active");
}

li.InnerHtml = helper.ActionLink(linkText, actionName, new { Id = id }).ToHtmlString();

return MvcHtmlString.Create(li.ToString());
}

Thursday 9 February 2012

Areas duplicated: Multiple types were found that match the controller named 'Home'.

Problem:

Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.

The request for 'Home' has found the following matching controllers:
Project.Web.Controllers.HomeController
Project.Web.Areas.Dashboard.Controllers.HomeController

Solution:

In Global.asax

    routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "Project.Web.Controllers" }
);

Tuesday 24 January 2012

The Web.config file is read-only

[IisWebSiteSequence] [ERROR] [10/17/2007 11:38:22 AM]: Access to the path 'C:\Inetpub\wwwroot\wss\VirtualDirectories\5003\web.config' is denied.

Network service and Network must have ‘write’ permisson.

Thursday 19 January 2012

SharePoint 2010 installation error: "The language of this installation package is not supported by your system"

 
1. OfficeServer.exe /extract:c:\SP2010
2.In Config.xml 
Add: <Setting Id="AllowWindowsClientInstall" Value="True"/>