Tuesday, July 27, 2010
How to add a picker to select a site or website and pass the selected site url in textbox
SharePoint field objects – classname, name and types
important fields.
Classname | Type | TypeAsString | TypeDisplayName | TypeShortDescription |
Microsoft.SharePoint.SPFieldBoolean | Boolean | Boolean | Yes/No | Yes/No (check box) |
Microsoft.SharePoint.SPFieldCalculated | Calculated | Calculated | Calculated | Calculated (calculation based on other columns) |
Microsoft.SharePoint.SPFieldChoice | Choice | Choice | Choice | Choice (menu to choose from) |
Microsoft.SharePoint.SPFieldComputed | Computed | Computed | Computed | Computed |
Microsoft.SharePoint.SPFIeld | ContentTypeId | ContentTypeId | Content Type Id | Content Type Id |
Microsoft.SharePoint.SPFieldCurrency | Currency | Currency | Currency | Currency ($, , ?) |
Microsoft.SharePoint.SPFieldDateTime | DateTime | DateTime | Date and Time | Date and Time |
Microsoft.SharePoint.SPFieldFile | File | File | File | File |
Microsoft.SharePoint.SPField | Guid | Guid | Guid | Guid |
Microsoft.SharePoint.SPFieldNumber | Integer | Integer | Integer | Integer |
Microsoft.SharePoint.Portal.WebControls.BusinessDataField | Invalid | BusinessData | Business data | Business data |
Microsoft.SharePoint.Publishing.Fields.ContentTypeIdFieldType | Invalid | ContentTypeIdFieldType | Content Type Id | Content Type Id |
Microsoft.SharePoint.Publishing.Fields.HtmlField | Invalid | HTML | Publishing HTML | Full HTML content with formatting and constraints for publishing |
Microsoft.SharePoint.Publishing.Fields.ImageField | Invalid | Image | Publishing Image | Image with formatting and constraints for publishing |
Microsoft.SharePoint.Publishing.Fields.LayoutVariationsField | Invalid | LayoutVariationsField | Variations | Page Layout Variations |
Microsoft.SharePoint.Publishing.Fields.LinkField | Invalid | Link | Publishing Hyperlink | Hyperlink with formatting and constraints for publishing |
Microsoft.SharePoint.Publishing.Fields.PublishingScheduleEndDateField | Invalid | PublishingScheduleEndDateFieldType | Publishing Schedule End Date | Publishing Schedule End Date |
Microsoft.SharePoint.Publishing.Fields.PublishingScheduleStartDateField | Invalid | PublishingScheduleStartDateFieldType | Publishing Schedule Start Date | Publishing Schedule Start Date |
Microsoft.SharePoint.Publishing.Fields.SummaryLinkField | Invalid | SummaryLinks | SummaryLinks | Summary Links data |
Microsoft.Office.Server.WebControls.FieldTypes.SPFieldTargetTo | Invalid | TargetTo | Audience Targeting | Audience Targeting |
Microsoft.SharePoint.SPFieldLookup | Lookup | Lookup | Lookup | Lookup (information already on this site) |
Microsoft.SharePoint.SPFieldLookup | Lookup | LookupMulti | Lookup | Lookup (information already on this site) |
Microsoft.SharePoint.SPFieldNumber | Number | Number | Number | Number (1, 1.0, 100) |
Microsoft.SharePoint.SPFieldRecurrence | Recurrence | Recurrence | Recurrence | Recurrence |
Microsoft.SharePoint.SPFieldMultiLineText | Note | Note | Multiple lines of text | Multiple lines of text |
Microsoft.SharePoint.SPFieldText | Text | Text | Single line of text | Single line of text |
Microsoft.SharePoint.SPFieldUrl | URL | URL | Hyperlink or Picture | Hyperlink or Picture |
Microsoft.SharePoint.SPFieldUser |
SPSite site = new SPSite("http://office2007");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Documenten"];
// Add a new text field
list.Fields.Add("NewTextField", SPFieldType.Text, false);
// Add a new HTML field
HtmlField htmlField = new HtmlField(
list.Fields, "HTML", "NewHTMLField");
list.Fields.Add(htmlField);
Wednesday, July 14, 2010
Internal mechanism of showing indicator of long operations in Sharepoint using SPLongOperation
This is very informative blog
http://sadomovalex.blogspot.com/2010/07/internal-mechanism-of-showing-indicator.html
Open SPSite under RunWithElevatedPrivileges in proper zone
http://sadomovalex.blogspot.com/2010/01/open-spsite-under-runwithelevatedprivil.html
Tuesday, July 13, 2010
Fire a button click event when user press enter key from textbox
http://sadomovalex.blogspot.com/2009/12/post-login-form-without-submit-button.html
Camlex.NET simplifies creating of CAML queries for Windows SharePoint Services by using expression trees
Contributors have done a great job.
Check this for more info on Camlex.NET
http://camlex.codeplex.com/
Check following link for good examples by Sadomovalex for camlex
http://sadomovalex.blogspot.com/2010/06/build-dynamic-caml-queries-based-on.html
Cross-site and cross-site collection navigation in Sharepoint
http://sadomovalex.blogspot.com/2010/05/cross-site-and-cross-site-collection.html
Tuesday, July 6, 2010
Disable WebPart form validators when page is in edit mode
So we need to disable validators when page in in edit mode.
Solution
On WebPart user control
using Microsoft.SharePoint.WebPartPages;
protected void Page_Load(object sender, EventArgs e)
{
if (SPWebPartManager.GetCurrentWebPartManager(Page).DisplayMode != WebPartManager.BrowseDisplayMode)
validator.Enabled = false;
}
Showing image preview popup using div and javascript
Also if user selects the image as choice from combo the it should show real images if he selects the document then i need to show the one dummy image and on clicking that image it should open or save document.
Step 1:
<asp:GridView
...
<ItemTemplate>
<center>
<div runat="server" id="previewDocument" >
<a href="<%# DataBinder.Eval(Container.DataItem, "ItemUrl")%>" alt="Click to see preview." target="_blank" >
<img id="Img1" class="imgThumbnail" src="/_layouts/images/EgSpi/Default/document.gif" alt="Click to see preview." />
</a>
</div>
<div runat="server" id="previewImage" >
<img id="Img1" class="imgThumbnail" src="<%# DataBinder.Eval(Container.DataItem, "ItemUrl")%>" alt="Click to see preview." onclick="Large(this)" />
</div>
</center>
</ItemTemplate>
</asp:TemplateField>
....
</asp:GridView>
Step 2:
protected void grvResults_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HtmlGenericControl docPreview = (HtmlGenericControl)e.Row.FindControl("previewDocument");
HtmlGenericControl imgPreview = (HtmlGenericControl)e.Row.FindControl("previewImage");
if (ddlObjectType.SelectedItem.Text == Enums.Object_Types.Document.ToString())
{
docPreview.Visible = true;
imgPreview.Visible = false;
}
else
{
docPreview.Visible = false;
imgPreview.Visible = true;
}
}
}
Step 3:
<script language="javascript">
function Large(obj) {
var imgHeight = 240;
var imgWidth = 240;
var imgBoxHeight = 250;
var imgbox = document.getElementById("imgbox");
imgbox.style.visibility = 'visible';
var divImageContainer = document.createElement("div");
divImageContainer.id = "imgContainer";
divImageContainer.innerHTML = '';
var divClose = document.createElement("div");
divClose.id = "imgclose";
divClose.innerHTML = "X";
if (divClose.addEventListener) {
divClose.addEventListener('onclick', Out, false);
} else {
divClose.attachEvent('onclick', Out);
}
imgbox.innerHTML = '';
imgbox.appendChild(divClose);
var img = document.createElement("img");
img.src = obj.src;
if ((img.height > imgHeight) || (img.width > imgWidth)) {
img.style.height = imgHeight + 'px';
img.style.width = imgWidth + 'px';
}
else {
divImageContainer.style.height = (imgBoxHeight - img.height) / 2 + 'px';
imgbox.appendChild(divImageContainer);
}
imgbox.appendChild(img);
imgbox.style.left = (obj.offsetParent.offsetLeft + 70) + 'px';
imgbox.style.top = (obj.offsetParent.offsetTop) + 'px';
}
function Out() {
document.getElementById("imgbox").style.visibility = 'hidden';
}
</script>
Step 4:
#imgbox
{
position: absolute;
border: 1px solid #999;
background: #FFFFFF;
filter: Alpha(Opacity=100);
visibility: hidden;
height: 250px;
width: 250px;
z-index: 50;
overflow: hidden;
text-align: center;
vertical-align:middle;
padding-top:5px;
padding-left:5px;
}
#imgclose
{
position: absolute;
top: 0px;
right: 0px;
background: #858585;
cursor: pointer;
padding: 6px;
font: bold 12px verdana, sans-serif;
color: white;
}
.imgThumbnail
{
border:none;
cursor:hand;
height:14px;
width:14px;
border: 1px solid #999;
padding:1px 1px 1px 1px;
}
----------------------------------- Enjoy ---------------------------------------