A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Wednesday, January 18, 2006

Backing Up Sites with Frontpage

You can back up your SharePoint Portal using the Backup utility that comes with the portal but sometimes  you just want to back up a single site, not the whole portal. You can use Frontpage to accomplish this.


1. Open  your site in Frontpage.
2. Go to Tools > Server > Backup Web Site
3. Select "Include websites in archive" in the dialog box that will pop up.
4. Select a location and enter a name for the backup file and click Save. This will save your site as a backup (fwp file). FWP stands for Frontpage Web Package.
Similarly, you can easily restore your backed up site.
1. Go to Tools > Server > Restore Web Site
2. Select the location and file name of your backup file and click OK.
This will restore your site completely but I noticed that your permissions are not restored and you have to restore them manually but that is acceptable. Some times, you have a large site with numerous lists and it is wise to take back up of the site just in case you need it later. Taking backup of a large portal so that you can backup just one site can cost you resources, time and space. This is an easy way to do the job. Another way of taking backups is saving the site as a template and then importing that template in another location. This is a very good way of migrating sites from one server to another. We will discuss that tip next time.
 
-SSA

Tuesday, January 3, 2006

Where can I add my custom built ASPX page in SharePoint easily? Give me an easy solution, I am a beginner!

Category: Administration
Level: Beginner
Custom made ASPX pages or web applications can be deployed in the following location:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATELAYOUTS
If you have a single ASPX page that will be called from your SharePoint website or webpart then copy it in the following location:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions60TEMPLATELAYOUTS1033
Of course, you can also create an excluded path.

Populating InfoPath fields with SQL data (using managed code)

I know it's easy to populate InfoPath form fields with SQL data using data connections but there are certain scenarios where you may want to populate fields with SQL data using custom code. For example, consider a scenario where you form has different sections, and each section is filled with data from a different database. One way is to create multiple data connections in your form. The other way is to write custom code. This is not the only example, there can be different situations where writing your own code could prove useful. Another situation is when you want to validate data entered by a user. Simply, open a connection to your database and check the field's value against data in your database.
1. Create an InfoPath form and add a field and a button.
2. Field name is  "field1" which is the default name for a newly added field. You may want to change it to a name of your liking, for example, First Name, Last Name, Address, etc.
3. Double click the button (default name for the button is Ctrl_1) and select "Edit Form Code..." in the dialog box that opens.
4. Add following code in the click event of the button:
SqlConnection MyConnection = new SqlConnection("server=sqlserver;database=yourdatabase;UID=;PWD=;");
MyConnection.Open();
SqlCommand Cmd = new SqlCommand();
Cmd.Connection = MyConnection;
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = "select * from tblUser";
SqlDataAdapter DA = new SqlDataAdapter(Cmd);
DataSet DS = new DataSet();
DA.Fill(DS);

thisXDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = DS.Tables[0].Rows[1][1].ToString();

if(DS.Tables[0].Rows[1][1].ToString() == "John Doe")
{
thisXDocument.UI.Alert("User name is John Doe.");
}
Code explanation:
Open a connection to the database using a connection string. Connection string contains your sql server, database name and userid and password to access the database. Open the connection before making any transaction. Add your sql query in the command object:
Cmd.CommandText = "select * from tblUser";
Following line will add data from SQL DB to your form field:
thisXDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = DS.Tables[0].Rows[1][1].ToString();
"field1" is your field's name. In the line above, we are populating this field with Row 1, Column 1 of the table.
if(DS.Tables[0].Rows[1][1].ToString() == "John Doe")
{
    thisXDocument.UI.Alert("User name is John Doe.");
}
If DB field is equal to "John Doe" then display a message to the user.
You can also do the opposite, instead of populating a field with DB data, get a value from the form field and find a record against this value in the DB. You just need to pass the form field value in the sql query:
 Cmd.CommandText = "select * from tblUser where username='" + thisXDocument.DOM.selectSingleNode("/my:myFields/my:field1").text + "'";
Don't forget to add following namespaces in your code page:
using System;
using System.Data;
using System.Data.SqlClient;

Add following code to the project class:

public class InfoPathDBProject
{
    private XDocument thisXDocument;
    private Application thisApplication;

    public void _Startup(Application app, XDocument doc)
    {
        thisXDocument = doc;
        thisApplication = app;
    }

    //Application code

}


-SSA

Sunday, January 1, 2006

Test Office 2007 including SharePoint Server online; You just need IE 6

Now, you can test Office 2007 including SharePoint Server and SharePoint Designer online. There is no need to download any software. You just need IE 6 to use online Office. Following applications will be available for online testing:

Microsoft Office Access 2007, Excel 2007, InfoPath 2007, OneNote 2007, Outlook 2007, Outlook 2007 with Business Contact Manager, Outlook Web Access, PowerPoint 2007, Project Professional 2007, Publisher 2007, SharePoint Designer 2007, Visio 2007, Word 2007, SharePoint Services, Project Server 2007 and SharePoint Server 2007.

Here is the link:

http://www.microsoft.com/office/preview/beta/testdrive.mspx?showIntro=n

Click "Test Drive Microsoft Office" button on this page!

-SSA