Tuesday, March 4, 2014

Unable to display this web part. To troubleshoot the problem, open this web page in a Microsoft SharePoint Foundation-Compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web Server Administrator. Correlation ID


Locking webparts in webpart zone
Scenario:
We wanted to lock some of company wide Web parts in some of web part zones so they cannot be deleted or modified by another one for consistency purpose.

Solution:
WebPartZone supports a property LockLayout.Setting it to true did the trick.

This property basically controls whether or not Web Parts within the zone can be added, deleted, resized, or moved. The LockLayout property works the same regardless of whether the Web Part Page is in personal or shared view.<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left"  
Title="loc:Left" AllowCustomization="false"   AllowLayoutChange="false" 
 AllowPersonalization="true" LayoutOrientation="Vertical" LockLayout="true"  />


How does it work:
If set to True, the specific Web Part properties for each Web Part in the zone that are affected are: Zone (ZoneID), Part Order (PartOrder), Visible on Page (IsVisible), Height (Height), Width (Width), Allow Close (AllowRemove), and IsIncluded (the Close command on the Web Part menu). Other Web Part properties are not affected.

If set to False, the Web Part properties determine whether modifications can be made (along with the appropriate site permissions).

Get Current User Name using Jquery Onload in sharepoint

1.Down load two files from Jquery
a.jquery-1.8.2.min.js
b.jquery-.SPService-0.7.2.min.js
2.Write the following code after the following place holder in new.aspx of sharepoint list


<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script  src="../../SiteAssets/js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="../../SiteAssets/js/jquery.SPServices-0.7.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">
$(document).ready(function(){
  var thisUserAccount = $().SPServices.SPGetCurrentUser({ fieldName: "Title", debug: false });
  $("input[title='NotesAuthor']").val(thisUserAccount );
}
);
</script>
 


Saturday, March 1, 2014

Check the All the checkboxes in the gridview using JQuery

1. java script code:


<script type="text/javascript" language="javascript">
function SelectAllCheckboxes(chk) {
            $('#<%=GVIndents.ClientID %>').find("input:checkbox").each(function () {
                if (this != chk) {
                    this.checked = chk.checked;
                }
            });
        }
 </script>
2. gridview design code :

 <GridView ID="GVIndents" runat="server" AutoGenerateColumns="False"  >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox runat="server" Text="Approved" Checked="true" ID="chkAll"
       onclick="SelectAllCheckboxes(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkone" Checked="true" />
 </ItemTemplate>
 </asp:TemplateField>

<;/Columns>

</asp:GridView>

 
   
 

 

Monday, February 10, 2014

Send email using sharepoint


SPUser fielduser = itemuser.User;
toReceiver = fielduser.Email;
string date = Convert.ToDateTime(it["Next_Hearing_Date"]).ToString("dd/MMM/yyyy");
body = "<html><body> Hello " + itemuser.User.Name + ", <br/><br/> Hearing For :" + it["Title"]  +"is on"+ date + "<br/>" + "LegalCase Details:" + it["Brief_facts_about"] + "<br/><br/>" + "Thanks <br/>" + "Note:" + "This is System Generated Mail Please donot Replay.</body></html>";
 header = "Hearing For :" + it["Title"] + " is On Next date Of Hearing: " + date;
 //UserEmail is existing  or not.
if (!string.IsNullOrEmpty(toReceiver))
issend = SPUtility.SendEmail(contentDb.Sites[0].RootWeb, fAppendHtmlTag, fHtmlEncode, toReceiver, header, body);

Tuesday, January 21, 2014

Disable Browser Back Button Functionality using JavaScript


In this article, I am discussing how to prevent user from navigate to previous page using back button of the browse.
One cannot disable the browser back button functionality only thing that can be done is prevent them.
Below is the JavaScript snippets that needs to be placed in the head section of the page where you don’t want the user to revisit using the back button

<script type = "text/javascript" >
   function preventBack(){window.history.forward();}
    setTimeout("preventBack()", 0);
    window.onunload=function(){null};
</script>

Tuesday, January 7, 2014

Change All values in specific column in Datatable

 
    DataTable dt = new DataTable(); 
    DataRow[] rowList = dt.Select("Item_Id IS NOT NULL");
    foreach (DataRow dr in rowList)
       dr["employee_id"] = "NewValue";

Monday, January 6, 2014

Get Hierarchy from SQL DATABASE Tables

CREATE PROCEDURE SP_Fin_Get_All_AccountHeads_Group_Hierarchy
    @Group VARCHAR(100),
    @CompID VARCHAR(100)
AS
---SP_Fin_Get_All_AccountHeads_Group_Hierarchy 'Admnistrative Expenses', 'ANOOS'
BEGIN
DECLARE    @primary_account_head_group_id VARCHAR(100)
DECLARE @MaxDepth INT
    DECLARE @CurrentFiscal VARCHAR(50)
    SET @MaxDepth = 6;   
   
    ;WITH LedgerList AS(
                    SELECT isnull(account_heads_parent_id,0) AS ParentId,
                            account_heads_id AS Id,       
                            account_heads_code AS Code,
                            description AS Description,   1 AS Hierarchy
                    FROM fin_account_heads
                    WHERE account_heads_parent_id is null
                    AND primary_account_head_group_id=(select account_heads_group_id    from               fin_account_heads_group where account_heads_group_name =@Group)
                    and company_code = @CompID
                    AND is_active=1
                   
                   UNION ALL

                    SELECT AH.account_heads_parent_id AS ParentId,
                            AH.account_heads_id AS Id,       
                            AH.account_heads_code AS Code,
                            AH.description AS Description,
                            LedgerList.Hierarchy + 1 AS Hierarchy
                    FROM fin_account_heads AH
                    INNER JOIN LedgerList
                                ON AH.account_heads_parent_id = LedgerList.ID
                    WHERE AH.company_code = @CompID
                            AND LedgerList.Hierarchy < @MaxDepth
                    AND is_active=1
                    )   
                    SELECT * FROM LedgerList                   
End