Sunday, 6 October 2013

Get all library name in sharepoint using powershell


$s = Get-SPSite http://abcd:1111/sites/Demo1/
$wc = $s.AllWebs
foreach($w in $wc)
{
foreach($l in $w.Lists){
if($l.BaseTemplate -eq "DocumentLibrary")
{
Write-Host $l.Title"(Web: "$w.Title")"
}
}
}

Get all TableName and column name with datatypes in sql server

SELECT SysObjects.[Name] as TableName,
SysColumns.[Name] as ColumnName,
CASE SysTypes.[Name]
WHEN
'sysname'THEN
'nvarchar'
ELSE
SysTypes.[Name]
END
AS [Name]
,CASE SysTypes.[Name]
WHEN
'nvarchar'THEN
SysColumns.[Length] / 2
WHEN
'sysname'
THEN
SysColumns.[Length] / 2
ELSE
SysColumns.[Length]
END
AS [Length]
FROM
SysObjects INNER JOIN SysColumns
ON SysObjects.[Id] = SysColumns.[Id]
INNER JOIN SysTypes
ON SysTypes.[xtype] = SysColumns.[xtype]
WHERE SysObjects.[type] = 
'U'ORDER BY SysObjects.[Name

Friday, 4 October 2013

item level permission in SharePoint List

Solution:-

 1. Go to List setting.
 2. Click the Advance setting.
 In advance setting we have "Item-level Permissions" as one of option.
 This option have two sub options. For Read Access
 3. select "Read items that were created by the user"
 For Create and Edit access
 4.select "Create items and edit items that were created by the user"
 5.save the above settings.

SharePoint 2010 manage content and structure missing

Solutions:-

Step:-1

 Site actions
 Site settings
 Site collection administration
 Site collection features
 Activate this feature ‘SharePoint Server Publishing Infrastructure’

Step:-2

Site actions
Site settings-site actions
Manage site features
Activate this feature ‘SharePoint Server Publishing’

watermark example using jquery in asp.net

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript"
        src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js">
    </script>

    <style type="text/css">
        .water {
            font-family: Tahoma, Arial, sans-serif;
            color: gray;
        }
        .txtWidth {
            width: 200px;
        }
    </style>
    <script type="text/javascript">
        $(function () {

            $(".water").each(function () {
                $textbox = $(this);
                if ($textbox.val() != this.title) {
                    $textbox.removeClass("water");
                }
            });

            $(".water").focus(function () {
                $textbox = $(this);
                if ($textbox.val() == this.title) {
                    $textbox.val("");
                    $textbox.removeClass("water");
                }
            });

            $(".water").blur(function () {
                $textbox = $(this);
                if ($.trim($textbox.val()) == "") {
                    $textbox.val(this.title);
                    $textbox.addClass("water");
                }
            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="smallDiv">
            <h2>Watermark Example</h2>
            <br />
            <div>
                <asp:TextBox ID="txtUserName" class="water txtWidth" Text="User Name"
                    ToolTip="User Name" runat="server"></asp:TextBox><br />
                <br />
                <asp:TextBox ID="txtPassword" class="water txtWidth" Text="Password"
                    ToolTip="Password" runat="server"></asp:TextBox><br />
                <br />
            </div>
               <br />
            <br />
            <div>
                <asp:Button ID="btnSubmit" runat="server" Text="Login"  />
            </div>
            <br />
            <br />
        </div>
    </form>
</body>
</html>

Wednesday, 2 October 2013

Add Content editor web part in SharePoint 2010

1. Site Action
2. Edit Page
3. Editing Tools ->Insert
4. Web Part
5. Choose Media and Content Categories
6. Content Editor
7. Add


 Rename the Content editor web part in SharePoint 2010
1. Click the Content Editor
2. Edit Web Part
3. under Appearance
 4. Change the Title
5. Ok


Reduce the image size in Content editor

1. Site Action
2. Edit Page
3. Click the Content Editor
4. Edit Web Part
5. Double click the image
6. Picture tools will show in ribbon panel
7. Under Picture tools click Design
8. Then change the Horizontal Size and Vertical Size of the image
9. Save & Close


Add Link icon in Content editor

1. Site Action
2. Edit Page
3. Editing Tools ->Insert
4. Click the image
5. Click the link icon in the ribbon control Enter the Redirect url 

XML Data to CSV file using C#

Xml Code:-

<Employee>
  <Emp>
    <Name>Mohamed</Name>
    <Age>27</Age>
    <Salary>100000</Salary>
  </Emp>
  <Emp>
    <Name>Raja</Name>
    <Age>26</Age>
    <Salary>200000</Salary>
  </Emp>
  <Emp>
    <Name>uthaya</Name>
    <Age>30</Age>
    <Salary>450000</Salary>
  </Emp>
</Employee>

C# Code:-

MemoryStream ms = new MemoryStream();
            DataSet ds = new DataSet();
            ds.ReadXml(@"E:\Student.xml");
            if (ds.Tables[0].Rows.Count > 0)
            {
                StreamWriter writer = new StreamWriter(ms);
                writer.AutoFlush = true;

                foreach (DataColumn column in ds.Tables[0].Columns)
                {
                    writer.Write(column.ColumnName.ToString() + ",");
                }
                writer.WriteLine();

                foreach (DataRow Drow in ds.Tables[0].Rows)
                {
                    writer.Write(Drow["Name"].ToString() + "," + Drow["Age"] + "," + Drow["Salary"].ToString() + ",");
                    writer.WriteLine();
                }
            }
            using (FileStream file = new FileStream("E:\\Output.csv", FileMode.Create, FileAccess.Write))
            {

                ms.WriteTo(file);
            }

Monday, 30 September 2013

Programmatically get all listName in share point using C#

                  String SiteURL = "";
                  SPSite site = new SPSite(SiteURL);
                  SPWeb myWeb = site.OpenWeb();
                  foreach (SPList aList in myWeb.Lists)
                  {
                      string ListTitle = aList.Title;
                      //string rootName = aList.RootFolder.Name;
                  }