Posts

Showing posts from November, 2012

SharePoint: Add existing field to content type using PowerShell

This Power S hell Script is used for add existing site field or column to a content type:     cls Remove-PSSnapin Microsoft.SharePoint. Powershell -ErrorAction SilentlyContinue Add-PSSnapin Microsoft.SharePoint. Powershell $site = Get-SPSite -Identity " Your Site Url " $web = $site.RootWeb $ct=$web.ContentTypes[" ContentType "]; $fieldAdd=$web.Fields[" Field Name "] $fieldLink=New-Object Microsoft.SharePoint. SPFieldLink($fieldAdd) $ct.FieldLinks.Add($fieldLink) ; $ct.Update() $web.Dispose() $site.Dispose()    

ASP.NET : Dirty Form(data save confirmation on unload form using jquery)

Image
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title>     <script type="text/javascript" src="jquery-1.3.2.min.js"></script>     <script type="text/javascript">         var initialdata = "nothing";         $(document).ready(function () {             initialdata = $('#Panel1 *').serialize();         });         function CheckFormDirty() {             var frmData = $('#Panel1 *').serialize();             if (WarnIfDirty(frmData)) return false;         }         function WarnIfDirty(frmData) {             if (initialdata != frmData) {                 r

ERROR:Operation is not valid due to the current state of the object.

ERROR:Operation is not valid due to the current state of the object.  When you send more than 1000 control within a single post request then this type of error will occur Solution:  Add an appsetting in WebConfig:  <appSetting>  <add key="aspnet:MaxHttpCollectionKeys" value="20001"/>  //in the value field put the number of controls you want to send in post request for example-20001.  </appSetting>

Drop Down Under Repeater Using VB.NET

Bind Drop Down with Reapter:  <asp:Repeater runat="server" ID="rp_DropDown" OnItemDataBound="rp_DropDown_ItemDataBound">    <HeaderTemplate>         <div>                 DropDown         </div>     </HeaderTemplate>    <ItemTemplate>         <div>               <asp:DropDownList ID="DropDown1" runat="server"                OnSelectedIndexChanged="DropDown1Changed" AutoPostBack="true">                 </asp:DropDownList>          </div>                                   </ItemTemplate>  </asp:Repeater> Bind Data In Drop Down: Dim DropDown1 As DropDownList = CType(e.Item.FindControl("DropDown1"), DropDownList)   Dim DataList As IList(Of String) = New List(Of String)   DataList.Insert(1,"ABC")   DataList.Insert(2,"DEF")   DataList.Insert(3,"GHI")   DropDownList .DataSource = DataList    DropDo