Friday, May 29, 2009

Building your ASP.NET MVC application with Subsonic 3.0

Subsonic really rocks... I loved Subsonic 2.0 and took the risk of starting a huge application using Subsonic a year ago while it wasn't that popular when comparing it to other DAL generators like .NetTiers template of codesmith. But to be honest, I loved subsonic since then very much, being so easy, light, straight forward, not complex, and what is the most important, getting things done just the way I want them.

Suddenly, Rob Conery introduced the new Subsonic 3.0 which is targeting the ASP.NET MVC technology. This sounds really great, and I liked the idea so much, but the question is.. Where can I learn it from? So far, all screen casts that Rob did are kind of "showing off" the new subsonic. Nothing published so far showing you how to create an application from scratch using Subsonic on Database called XYZ for instance like he used to do with earlier versions. Maybe he is waiting for the final release of Subsonic 3.0 to do so.

I liked Rob Conery's comment that he added in Preview 2's package. It was something like "This is a Preview version.. so BE GENTLE".


Anyway, I am really waiting for this version of subsonic, I guess it will be a good plus for using ASP.NET MVC.

Now lets talk about Subsonic, and how to get your application working using subsonic 3.0. Please note, that Subsonic 3.0 is a brand new tool, and am not that good in it. I learnt that from trial errors, so don't hesitate to correct me if am wrong in anything am posting.

Prerequisites

  • Install MVC into your visual studio from here.
  • Install Subsonic Template from here.

Installation of the MVC on Visual Studio is a straight forward issue. You have to run the msi file and you are done.

For subsonic, Place the zipped file you downloaded into the following directory (My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual Web Developer\Web). Don't extract the zip file, but keep it there as it is.

Starting your application

Open Visual Studio. Then from the files menu, Create a new Project.

As shown below. Choose the Subsonic MVC Template, then press ok.

1

The solution structure will look exactly like that:

SolutionStructure

Now, open the web.config file, and edit the connection strings. This is the main part, as everything is based upon the DB you are using. The whole DAL will be generated according to the Database. Dont forget to change the Database name as well. We will later make the subsonic get to know the new name.

<connectionStrings>     <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>     <add name="Chinook" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Chinook.mdf;User Instance=true" providerName="System.Data.SqlClient"/> </connectionStrings>

Now here we come to the tricky part, that caused me a lot of confusions. I used to miss this part and end up all the time hitting my head against the wall.

Open the Model/_settings.tt file. This is one of the T4 templates subsonic is using. Edit this part:

const string Namespace = "SubSonic.Web.Models"; const string ConnectionStringName="Chinook";

Now you can change the ConnectionStringName to the name you defined in the web.config section, then save the file.

Creating the DAL

Right click on the _settings.tt file, and select the "Run Custom tool" option as shown below. Repeat this step with the 4 Template files in the Models directory.

RunCustomTool

You will find some warning messages in the error list while running the template files; just neglect them. Always try to remember Rob's phrase I stated earlier; "Be Gentle, this is a preview version" ;) So I guess it's better to choose not to show the warning messages in the error list :)

Now time to build. Oops, 3 errors? Let me tell you that now you can say "I successfully generated my DAL using Subsonic!!" They are as simple as adding this line "using SubSonic.Web.Models;" into HtmlExtensions.cs and SubsonicRepository.cs files.

errorList

Now we are done.

You can learn how to create the Models, Views, and controllers using subsonic's tools, I recommend watching Rob's screencast. Although he showed everything quickly and without any explanations, but I think it doesn't need any.

Correct me if am wrong in any of the tips I stated. I told you, no one knows better than the other when it comes to beta editions of software ;)

Sunday, April 5, 2009

Creating your own site's search Engine

Setting up you search page for your web application is as easy as having a DB table where you retrieve data from by a simple query. I will illustrate the steps of setting up the configurations needed in this post, and will write another one for detailed stuff in custom search page. So lets start.


Setting up your Search Index

  1. start>run> type mmc
  2. in the new window, File> Add Remove Snap-in, or press CTRL + M as a shortcut
  3. Press Add, and choose Indexing Service from the List box as shown below
    clip_image001
    Press the Add button.
  4. A dialog box will appear asking you about the Computer name you want to apply the Indexing on, choose the local computer for this Demo.
    clip_image002
  5. Close all dialogs you have on your screen until you reach your Console Window, with Indexing Service running.
  6. Right Click on the Indexing Service node under the Console Root, and choose New>Catalog.
    Make sure that the Start option in the menu is activated before doing this step, otherwise, you have to stop the service first.
    clip_image003
  7. Give the new Catalog any Name. I will call it PP4.
    Browse to a directory where the Catalog file will be stored in. This is not the directory which you want to Index.
    clip_image004
  8. You will find a new node called PP4 just appeared under the Indexing Service node.
    Now we want to tell the new Catalog to search in your site. Right click on the PP4 Catalog, and choose New>Directory
    clip_image005
  9. Now fill in the Data as below
    clip_image006
    The Path, is the Physical Path of the website you'd like to Index. Finally press OK.
  10. Now right click on the PP4 Catalog, and choose Properties. Go to the tracking tab, and change the WWW server to your Default Website.
    clip_image007
  11. Now go to the Generation tab, and uncheck the checkbox "Inherit above settings from Service".
    clip_image008
    It Enables by default the "Generate abstracts" checkbox. This tells the search index, to get some text from the searched pages, just like Google.com for instance when they get you a sample text under each item in the search result. The default is not generate any abstracts. This text is by default the first 320 characters in the page. You can customize that just by adding some text in the "description" meta tag in the HTML's head section.
  12. Now start the Service.
    clip_image009

Now we are done with setting up the search index configurations. Next you have to create a page that calls this catalog for searching. But before doing this, lets try to figure out whether everything is working fine or not.

 

Querying your Search Index through the built in page

Under the PP4 Catalog we have just created, you will find a node called "Query the Catalog". Press on that node and a page will load up at the right part of the window as shown below. Here you can try by typing "Partners" for instance, and have a look at the query result. As you can see, the query includes .cs, .vb, .css files and many other types of unwanted files. you can control that by creating your own page, using your own code.

clip_image010

 

Querying your Search Index through a custom page using Query Language

I will go through the main parts of the query, and you can figure out the rest. It's as if you are querying a simple SQL Database and binding the results to a Repeater.

Connection:

    OleDbConnection odbSearch = new OleDbConnection( "Provider=\"MSIDXS\";Data Source=\"PP4\";");

    Please note that the Data Source is the Catalog name you specified in the Search Index configurations.

Command:

    cmdSearch.Command Text = "select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '"+ searchText +"') order by  rank desc ";

Where the "searchText" is the text you typed in the textbox for searching.

The rest is as easy as executing the query and binding the results to a repeater. I have made one on my own and took a snap shot of the running program below:

clip_image011

Wednesday, November 26, 2008

Visual Studio Themes Gallery

Tired of the default color theme you are using in Visual Studio? the ordinary white background, black text, blue keywords, and the green comments..

For me, I wished I could find a nice neat theme that would change everything up, and make the Visual Studio look so much different (kind of fooling myself Open-mouthed).


Anyway, have a look at these images bellow.. and think again Wink

Visit this page for a good downloadable collection..Press here

Tuesday, August 12, 2008

Creating a Custom SharePoint MasterPage using a Feature

Creating a custom MasterPage is a very common requirement especially for those who want to migrate from ASP.NET 2.0 to SharePoint, without altering the look and feel they already had previously.

I have searched a lot about how to accomplish this, and found many articles and blog posts but they are all incomplete, they are missing the complete guide. I will try to be as direct as possible, and include screen shots that I hope they would help.

Anyway, lets start and get our hands dirty...


  1. Navigate to the following folder: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\
    Copy the PageLayouts folder and paste it in the same directory but Change the folder name to another one. To easily follow up with me through this post, lets call it CustomMasterPages.

     

    Add the masterpage you want in the masterpage folder, the CSS file into the styles folder, and all images you need into the images folder.
  2. Open the CustomMasterPages folder. Now we have to Edit the Feature.xml that has the main Registry info about the new feature you want to create (in our case, the custom MasterPage). So open the feature.xml file using your favorite text editor.
    Delete what the file has, and paste the following:

    <!-- _lcid="1033" _version="12.0.4518" _dal="1" -->
    <!-- _LocalBinding -->
    <Feature  Id="77596cae-c12d-4451-9d65-53b66b2fd5aa"
              Title="CS Masterpage"
              Description="My own Custom MasterPage"
              Version="12.0.0.0"
              Scope="Site"
              Hidden="False"
              DefaultResourceFile="core"
              xmlns="http://schemas.microsoft.com/sharepoint/">
        <ElementManifests>
            <ElementManifest Location="ProvisionedFiles.xml"/>
        </ElementManifests>
    </Feature>

    You have to change only the following fields, but I advice you to leave everything as it is for this Demo, just as a good kick off :)
    ID: A GUID to identify the feature. you can go to http://www.newguid.com/ to generate a new GUID (you will find it in the upper banner) and paste it right there.
    Title: the Feature name (Custom MasterPage name).
    Description: Feature's description.
    The Element Manifest is considered as the backbone of the feature; you have to specify its location, which is by default named as ProvisionedFiles.xml located at the same level with the feature.xml. Save the file and close it.

  3. Now open the ProvisionedFiles.xml file and let's see what we have got there.
    You simply link EVERYTHING you have in the CustomMasterPages folder, and create an entry for it in the ProvisionedFiles.xml

    <!-- _lcid="1033" _version="12.0.4407" _dal="1" -->
    <!-- _LocalBinding -->
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="OSGMasterPages" Url="_catalogs/masterpage" Path="MasterPages" RootWebOnly="TRUE">
    <!--the MasterPage file that you have to put in the CustomMasterPage/MasterPages folder -->
        <File Url="MasterPage.master" Type="GhostableInLibrary">
        <Property Name="ContentType" Value="My Sample Master Page" />
    <!-- a preview image for the MasterPage file. Put the image in the CustomMasterPage/en-us folder -->
    <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlackVertical.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlackVertical.png" />
    <!-- MasterPage Description -->
    <Property Name="MasterPageDescription" Value="This is my sample master page for use with collaboration or publishing sites." />
        </File>
    </Module> <!-- a preview image for the MasterPage file. Put the image in the CustomMasterPage/en-us folder -->
    <Module Name="PublishingLayoutsPreviewImages" Url="_catalogs/masterpage" IncludeFolders="??-??" Path="" RootWebOnly="TRUE">
        <File Url="BlackVertical.png" Name="Preview Images/BlackVertical.png" Type="GhostableInLibrary">
        </File>
    </Module>
    <!-- The place where we can add the registry info of the images used in the MasterPage-->
    <Module Name="Images" Url="Style Library/Images" Path="Images" RootWebOnly="TRUE">
    <!-- All images that you added previously in the CustomMasterPage\images folder, each will have its own entry as shown below, with the same syntax except the Url, and name. Please take care that they are case sensitive-->
    <File Url="1_Duane.jpg" Name="1_Duane.jpg" Type="GhostableInLibrary"/>
    </Module> <!-- Styles, the name of the css file located in the CustomMasterPage\styles folder-->
    <Module Name="OSGStyles" Url="Style Library" Path="Styles" RootWebOnly="TRUE">
            <File Url="CS MasterPage.css" Type="GhostableInLibrary" />
    </Module> </Elements>

    Now we are done with the 2 most important pages.

  4. One important thing you must take care of, is that the masterpage design is not the same as what you used to do in ASP.NET 2.0. Its not an HTML page with some ContentPlaceHolders with random IDs and placed anywhere like before. SharePoint's MasterPages are way different; there are a number of predefined ContentPlaceHolders with specific ids (you can't change them, or they wont be recognized, and the MOSS will hit you with a silly frustrating error page!). These ContentPlaceHolders are recognized by the MOSS according to their IDs. Have a look at the complete list below:



    yet, you dont have to place ALL of these ContentPlaceHolders into your new customized MasterPage. there are some of these which are essential, and others not. The following is a minimal MasterPage that you cant remove anything from it, or it wont work at all. You can always use it as a start for designing your masterpages.. i.e NEVER START THE MASTERPAGE DESIGN FROM SCRATCH! or you will end up banging your head against the wall!

    <%-- Identifies this page as a .master page written in Microsoft Visual C# and registers tag prefixes, namespaces, assemblies, and controls. --%>
    <%@ Master language="C#" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
    <%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>
    <%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>
    <%@ Register Tagprefix="PublishingConsole" TagName="Console" src="~/_controltemplates/PublishingConsole.ascx" %>
    <%@ Register TagPrefix="PublishingSiteAction" TagName="SiteActionMenu" src="~/_controltemplates/PublishingActionMenu.ascx" %>
    <%-- Uses the Microsoft Office namespace and schema. --%>
    <html>
      <WebPartPages:SPWebPartManager runat="server"/>
      <SharePoint:RobotsMetaTag runat="server"/>   <%-- The head section includes a content placeholder for the page title and links to CSS and ECMAScript (JScript, JavaScript) files that run on the server. --%>
      <head runat="server">
        <asp:ContentPlaceHolder runat="server" id="head">
          <title>
            <asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server" />
          </title>
        </asp:ContentPlaceHolder>
        <Sharepoint:CssLink runat="server"/>
        <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
      </head>
      <%-- When loading the body of the .master page, SharePoint Server 2007 also loads the SpBodyOnLoadWrapper class. This class handles .js calls for the master page. --%>
      <body onload="javascript:_spBodyOnLoadWrapper();">
        <%-- The SPWebPartManager manages all of the Web part controls, functionality, and events that occur on a Web page. --%>
        <form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
          <wssuc:Welcome id="explitLogout" runat="server"/>
          <PublishingSiteAction:SiteActionMenu runat="server"/> 
          <PublishingWebControls:AuthoringContainer id="authoringcontrols" runat="server">
            <PublishingConsole:Console runat="server" />
          </PublishingWebControls:AuthoringContainer>
          <%-- The PlaceHolderMain content placeholder defines where to place the page content for all the content from the page layout. The page layout can overwrite any content placeholder from the master page. Example: The PlaceHolderLeftNavBar can overwrite the left navigation bar. --%>
          <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />
            <asp:Panel visible="false" runat="server">
            <%-- These ContentPlaceHolders ensure all default SharePoint Server pages render with this master page. If the system master page is set to any default master page, the only content placeholders required are those that are overridden by your page layouts. --%>
                <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea"  runat="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server"/>
                <asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server"/>
                <asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server"/>
                <asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server"/>
                <asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server"/>
                <asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server"/>
                <asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat ="server" />
                <asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat ="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat ="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat ="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat ="server"/>
                <asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server" />
            </asp:Panel>
        </form>
      </body>
    </html>

    So to start, you can get whatever HTML you have in the old MasterPage and paste it in here, just below the </asp:Panel>. Then arrange the ContentPlaceHolders wherever you want into your HTML code.
    Another point you must take care of; the images and background's source urls. of course, we added the images previously into the CustomMasterPages\images folder, so we will replace the old source urls you had in the html code into something like:
    background="/Style%20Library/images/bg1.jpg">
    and for sure, that would be the same case in the CSS file.

  5. Now we are ready to install the feature!
    open the command prompt (Start> Run), then type:
    cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
    Now type the following
    stsadm -o installfeature -filename CustomMasterPages\feature.xml
    We are installing the feature that we are providing its feature.xml file (the xml file's path from the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES folder).
  6. Activate the feature for your site.
    open the Internet Browser, and type in the webapplication's URL.. something like http://ahmed-ig:35193 and concatenate /_layouts/settings.aspx to the previous part.
    i.e: http://ahmed-ig:35193/_layouts/settings.aspx

    under the "Site Collection Administration" column, click on "Site collection features"

     

    locate the Feature you have just made. (you will find its name as you named it in the feature.xml file)

     

    Now Press on the Activate Button to activate the Feature.

  7. Apply the MasterPage into your site
    Now get back to the url you opened in Step #7
    and under the "Look and Feel" column, click on "Master page".
    Choose the Site Master Page as the customized MasterPage you have created.
    and leave the System Master Page as it is.
    Now you have to upload the CSS file you are using in your customized MasterPage file.

     

And Hopefully, that's it! Hope it works smoothly without any problems :)

Sunday, May 25, 2008

A Simple GUI Tool for SQL 2005 Reports deployment without using BI Development Studio

Introduction

SQL 2005 Reports deployment is done either by choosing the deploy option in the BI Development studio, then specifying the target Server URL and the target Report Folder, which is the standard way, or deploying the reports manually by opening the Report Server URL, and creating the DataSource, the parent Folder where you will add the datasource and report in, and the attaching the Reports manually, which is still not that realistic as you don't have to do all that each time you want to deploy a report. Yet the first option is not always possible, as you may wish to deploy a report while you don't have the BI development Studio installed in your machine. In this article, I expect that you know both techniques before reading, as I won't be explaining in details everything.

I made a simple GUI tool that helps in deploying the SQL Reports by consuming the web service named reportservice.asmx that the SQL Reporting Server produces and hosted by the IIS of the Report server. Usually the Report Server has the URL as:
http://<server name>/ReportServer
and sometimes as http://<server name>/ReportServer$SQLExpress, or http://<server name>/ReportServer$SQL2005. This is according to what you named the SQL server Instance installed. Anyway, let's get back to the main point. The webservice within the ReportsServer web application hosted in the IIS of the server machine actually does everything you need to deploy the Reports you want; I guess it is better to have a look at the ReportingService2005 Methods.

Anyway... Let's start having a look at the application and the code. First I will be investigating the application, and what does everything means, then we will have a quick review on the main parts of the code.

How to use the Tool ?

Once you run the application, a window will appear asking you to enter the Report Manager URL, as to connect to its web service. I.e. it's the same URL you type in the target server URL property when using the BI Development Studio for deployment. The URL you entered is saved then so that you don't have to type it in each and every time you run the application. I use this URL, so as to modify the WebService I am consuming, to connect to the URL you will choose. To know what I mean, just have a look at this article by Christopher G. Lasater, that describes what I did actually (Dynamic Web Service).

After the previous step is done, the Web Service now is made ready to do the rest.

Next, to get started, you have to define the following:

  1. The connection string as the data source.
  2. The Data source name.
  3. The Report source (Physical Path in your machine).
  4. The Report Name (The name that you will give to the Report you just browsed for).
  5. Finally, the folder (a logical folder in the Report Server not a physical folder in your machine) which you will save in it the Reports and the data sources you want.

Finally, after running the Tool successfully, then tried to open the SQL Server Reporting Services Web application, you will find a new Folder as you named in the tool, and has the DataSources and Reports you made as below.

Code Overview

If you had a look at the ReportingService2005 Methods, you will find the two main functions that you will be using mainly. They are the CreateDataSource function, and the CreateReport function.

A brief description of how to use the article or code. The class names, the methods and properties, any tricks or tips.

This is the part which Creates the DataSource

public void CreateReportDataSource(string name, string extension, string connectionString)
{
listView1.Items.Add("Creating Data Source [" + txt_DataSource.Text + "]");
ReportService.DataSourceDefinition definition = new ReportServerInstaller.ReportService.DataSourceDefinition();
definition.CredentialRetrieval = ReportService.CredentialRetrievalEnum.Integrated;
definition.ConnectString = connectionString;
definition.Enabled = true;
definition.Extension = extension;

try
{
rs.CreateDataSource(name, FolderName, chk_DataSourceOverwrite.Checked, definition, null);
listView1.Items.Add("Data source: [" + name + "] created successfully.");
TS_Progress.PerformStep();
}
catch (Exception ex)
{
listView1.Items.Add("ERROR creating data source: " + name);
throw ex;
}
} 

And here is the part which Publishes the report

private void PublishReport(string reportName)
{
listView1.Items.Add("Publishing Report [" + reportName + "]");
FileStream stream = File.OpenRead(ReportSource);
definition = new byte[stream.Length];
stream.Read(definition, 0, int.Parse(stream.Length.ToString()));
stream.Close();

try
{
rs.CreateReport(txt_ReportName.Text, FolderName, chk_ReportOverwrite.Checked, definition, null);
listView1.Items.Add("Report: [" + reportName + "] created successfully.");
TS_Progress.PerformStep();
}
catch (Exception ex)
{
listView1.Items.Add("ERROR creating Report: " + reportName);
throw ex;
}

}

I have attached an installer for easy use of the tool. You don't have to configure anything before use. Just insure that you have the correct SQL Manager URL typed in the first form, as this does everything. Happy Deployment! ;)

Download Source Code Download Demo

Thursday, April 3, 2008

How To: Create Custom Pages with Custom Content Type

Hi again :)

Those are a simple steps to create your Custom Content Type, then create Pages based on that Content Type.


Create Content Type

Steps:

Site Actions > Site Settings > Modify All Site Settings

� Under 'Galleries' > 'Site content types'.

� In 'Site Content Type Gallery' page; Click 'Create'.

� Enter 'NewsContentType' in the 'Name' field.

� Select 'Page Layout Content Type' for the 'Parent Content Type'.

� In the 'Put this site content type into' section; select 'New group' -that's for better organization- and enter a name 'MY Content Types' for that group.

 

Create Columns for your Content Type

Steps:

� In 'Site Content Type: NewsContentType' page; under 'Columns' section; click 'Add from new site column'.

� For each of the following fields enter 'Column name', select the 'The type of information in this column', and specify the group of that column.

� The fields are: Title 'Single line of text', Date 'Date and Time', Source 'Single line of text', Brief 'Multiple lines of text', Description 'Multiple lines of text', and Image 'Image with formatting and constraints for publishing'.

 

Create Page Layout

Steps:

Open your site by SharePoint Designer

� File > New > 'SharePoint Content' tab > 'SharePoint Publishing' Section'

� Select 'Page Layout' from the list

� Under 'Options'; Select your Content Group, select your Content Type, Specify URL name, and Title.

� Now in your page layout, you can add fields from your existing Content Type:

        o Toolbox > SharePoint Contents > 'Your Content Type'.

� You will find your Page Layout saved under:

        o Catalogues > Master Page > 'Your Page Layout'

� Before using your Page Layout; you've to:

        o 'Save' and 'Check In' the page

        o Approve the Page Layout from 'Master Page Gallery'

 

Add Content Type to your Site

Steps:

Site Actions > Site Settings > Modify Pages Library Settings

� Under 'Content Types' > 'Add from existing site content types'

� In 'Add Content Types: Pages' page; Select 'MY Content Types' group; then select 'NewsContentType' content type from the list.

 

Create Page based on Content Type

Steps:

Site Actions > Create Page

� Enter 'Page Title and Description' information.

� Select 'Page Layout' that you just created

Tuesday, April 1, 2008

How to: Get Site Template Name

Hi all,

This is a simple topic, but it's very important to know how to get the SiteTemplate Name.


Steps:

  • Open "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML" directory (assuming you installed MOSS to this path).
  • In that directory, there are a number of xml files; Open the one called "webtempsps.xml"
  • In that file you will see an entry for a