Tuesday, December 29, 2009

asp.net email +Transaction failed. The server response was: Sending address not accepted due to spam filter

A very common error while sending email through ASP.Net code :
"Sending address not accepted due to spam filter"
To resolve this just pass the network credentials for a user and it will work.

Tuesday, December 15, 2009

FileUpload control does not work in Update Panel : solution

All file upload controls (includes asp, telerik, componentart, component factory and others) does not working in any AJAX update panels. This means if your upload control located in an update panel, control does not post the file. If you look to the posted file property of the control, you will see it null.

This is a limitation comes from the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application. In order to upload a file you should perform a full page postback.

The solution is to add a Triggers tag:

<asp:UpdatePanel ID="upFileUpload" runat="server" >

<Triggers>

<asp:PostBackTrigger ControlID="btnUpload" />

</Triggers>

<ContentTemplate > .....

</ContentTemplate>

</asp:UpdatePanel>

See it work like a charm!!

Saturday, December 5, 2009

Issue with the ajax tab panel

In case your AJAX Tabs are not rendered properly and you get white line/space then quick fix will be to define the height of Tabs.


Define the following CSS below and reference in your TabContainer and things will work well .

<style type="text/css">

.ajax__tab_xp .ajax__tab_tab

{

height: 21px;

}

</style>




Wednesday, November 18, 2009

SharePoint : Setting List column values

Here is the code snippet where I am setting a List column called "Has Payment" depending on few conditions:

string strSiteCollPath = "your Site Collection path";
using (SPSite siteCollection = new SPSite(strSiteCollPath))
{
using (SPWeb siteWeb = siteCollection.OpenWeb())
{
SPList lstPayment = siteWeb.Lists["XYZ"];
SPList lstInvoiceSummary = siteWeb.Lists["ABC"];

foreach (SPItem item in lstInvoiceSummary.Items)
{
string strDocNumber = item["documentNumber"].ToString();
SPQuery query = new SPQuery();
query.Query = "your SPQuery";
SPListItemCollection coll = lstPayment.GetItems(query);
int count = coll.Count;

if (count > 0)
{
item["Has Payment"] = "Yes";
item.Update();
}
else
{
item["Has Payment"] = "No";
item.Update();
}
}
}
}

Basic SilverLight WebPart

Here goes the link to a Basic Hello World Silver Light webpart
http://philwicklund.com/archive/2008/05/26/how-to-build-a-%E2%80%9Chello-world%E2%80%9D-silverlight-web-part-for-a-sharepoint-site-in-10-easy-steps-part-2-of-2-deploying-a-silverlight-application-into-sharepoint.aspx

Monday, November 9, 2009

C# :Writing DataTable to a text file

Here goes the code to write a data table to a text file:

//Writing to a text file
int count = 0;
StreamWriter sw = null;
try
{
sw = new StreamWriter(@"C:\Users\asoory\Desktop\UniqueConsultantNames.txt", false);
for (count = 0; count < dtList.Columns.Count - 1; count++)
{
sw.Write(dtList.Columns[count].ColumnName + "");
}
sw.Write(dtList.Columns[count].ColumnName);
sw.WriteLine();
foreach (DataRow row in dtList.Rows)
{
object[] array = row.ItemArray;
for (count = 0; count < array.Length - 1; count++)
{
sw.Write(array[count].ToString() + "");
}
sw.Write(array[count].ToString());
sw.WriteLine();
}
sw.Close();
}
catch (Exception ex)
{
}

Thursday, November 5, 2009

SPQuery Error :One or more field types are not installed properly. Go to the list settings page to delete these fields

I kept receiving this error for a list when I was using a SPQuery to fetch items from it.
"One or more field types are not installed properly. Go to the list settings page to delete these fields"
The error came up because one of the fields I was calling was not a column of the list.
I removed it from the CAML query and it worked.
So ,I guess this error crops up when the CAML is not properly formed.
U2U CAML query builder is very useful in debugging such errors.

Wednesday, September 16, 2009

MOSS 2007 limitations

As with every application MOSS 2007 has limitations .

However, I think you will see these limitations are such that they will have little impact in virtually any enviroment.

Microsoft Office SharePoint Server (MOSS) 2007 Limits

Site Collections in a Web Application50,000
Sites in a Site Collection250,000
Sub-sites nested under a Site2,000
Lists on a Site2,000
Items in a List10,000,000
Documents in a Library2,000,000
Documents in a Folder2,000
Maximum document file size2GB
Documents in an Index50,000,000
Search Scopes1,000
User Profiles5,000,000

Wednesday, September 2, 2009

MOSS 2007 webpart using CAML query

Here is a simple webpart using CAML query to fetch a particular value from a SharePoint List.
I have an announcement list and I am searching for a "Title" corresponding to a field called "Posted By" in the same list. I use the u2u CAML query builder to build CAML queries.Here goes my webpart code:

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Data;
using System.Diagnostics;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.Utilities;
namespace WSPBuilderProject1
{
[Guid("be9d2bda-11ef-43e2-bad3-85e5238a1755")]
public class WebPartFeature1 : Microsoft.SharePoint.WebPartPages.WebPart
{
Label lbl;
protected override void CreateChildControls()
{
try
{ //Initializing my site collection url
string sUrl = "http://sm-cala-csx01:5318/sites/HRDep";
//Always use the "using" statement to ensure proper disposal of the SPWeb and SPSite objects.
using (SPSite siteCollectionOuter = new SPSite(sUrl))
{
//Initializing my web app url since my lists are in a subsite called Docs
using (SPWeb webapp = siteCollectionOuter.AllWebs["/sites/HRDep/Docs"])
{
//The list Ann Log to which I want to add data after Item is added to list Announcements
SPList annLog = webapp.Lists["Announcements"];
//Adding the Title field of the new item to my Ann Log list
SPQuery getItem = new SPQuery();
getItem.Query = "Rxiyer";
SPListItemCollection items = annLog.GetItems(getItem);
lbl = new Label();
if (items != null)
{
string strTitle = SPEncode.HtmlEncode(items[0].DisplayName.ToString());
//HtmlEncode(items["Title"].ToString());
//QueryFieldNames["Title"].ToString();
lbl.Text = strTitle;
}
else
{
lbl.Text = "error";
}
this.Controls.Add(lbl);
}
}
}
catch (Exception ex)
{
//Writing any exceptions to the event viewer under a source called SharePoint Features
if (!EventLog.SourceExists("SharePoint Features"))
EventLog.CreateEventSource("SharePoint Features", "Application");
EventLog.WriteEntry("SharePoint Features", ex.ToString());
}
}
}
}

Tuesday, September 1, 2009

Infopath and Webservice reference

http://blogs.msdn.com/jannemattila/archive/2007/01/21/infopath-and-web-service-data-connection.aspx
http://blogs.msdn.com/philoj/archive/2005/11/08/490200.aspx

http://msdn.microsoft.com/en-us/library/aa192516(office.11).aspx

MOSS 2007: Event handler code to add item to a list

I wanted to update a list called "Ann Log" when a new item is added to a "Announcement" list.
So, I used to ItemAdded method of the event handler.
The simple steps are as follows:

  • I use the WSPBuilder project to create and deploy custom code on my portal since WSP builder makes my life really simple.You can download WSPBuilder add in to Visual Studio from here:http://wspbuilder.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30858
  • Now create a new project of type WSPBuilder .
  • I named it "ListItemFetcher".
  • Add a new item of the type "EventHandler". Keep the scope as "Web".It will automatically create a folder structure with feature.xml and element.xml.
  • In the elements.xml make the receiver type as "ItemAdded" and for Announcements list make the template id as "104"
  • Next open the EventHandler1.cs file and write the code for ItemAdded.
  • Here is my code snippet.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Diagnostics;
namespace ListItemFetcher
{
public class EventHandler1 : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
try
{ //Initializing my site collection url
string sUrl = "
http://sm-cala-csx01:5318/sites/HRDep";
//Always use the "using" statement to ensure proper disposal of the SPWeb and SPSite objects.
using (SPSite siteCollectionOuter = new SPSite(sUrl))

{
//Initializing my web app url since my lists are in a subsite called Docs
using (SPWeb webapp = siteCollectionOuter.AllWebs["/sites/HRDep/Docs"])
{
//The list Ann Log to which I want to add data after Item is added to list Announcements
SPList annLog = webapp.Lists["Ann Log"];
//Adding the Title field of the new item to my Ann Log list
string item = properties.AfterProperties["Title"].ToString();
SPListItem annLogNewItem = annLog.Items.Add();
annLogNewItem["Title"] = item;
annLogNewItem.Update();
} } }
catch (Exception ex)
{
//Writing any exceptions to the event viewer under a source called SharePoint Features
if (!EventLog.SourceExists("SharePoint Features"))
EventLog.CreateEventSource("SharePoint Features", "Application");
EventLog.WriteEntry("SharePoint Features", ex.ToString());
} } }}
  • Now build and deploy the WSPBuilder project.If deploying to another machine use stsadm to deploy the WSP package.
  • Go onto SharePoint Central Admin -->Operations-->Solution Management and check if your ListItemFetcher.WSP is visible.
  • If yes bingo ! your solution has been deployed.
  • Go onto your Site Actions menu of your site -->Site Settings-->Site Features.
  • Activate the ListItemFetcher feature there and check by adding a new item to Announcements List it should add the same Title to Ann Log List.

  • Thursday, August 27, 2009

    Excel Services :Example

    Excel Services has several offerings and the one I would like to discuss in this post is how useful Excel Services programming could be for a Business.
    A person in an organization could define business logic and models on an excel spreadsheet .A developer could create a user interface for an end user to use the logic and get results.The developer could do this by calling the Excel Services web service to get the logic from the spreadsheet, perform calculations and publish the results on a user interface.
    Whenever the business logic needs to be changed there is no need for the developer to be involved . A person can just go and modify the logic or rule and the excel services would work with the new logic automatically.

    A very common example of Excel Services to demonstrate the same is "an Excel Services Mortgage Calculator".
    To refer to the same you can go to:http://msdn.microsoft.com/en-us/library/aa973804.aspx

    MOSS 2007 : psconfig.exe

    Use and Need of psconfig.exe in MOSS 2007

    In SharePoint Products and Technologies, you can use the psconfig.exe command-line tool as an alternate interface to perform several operations that control how the SharePoint Products and Technologies are configured. You must be a member of the Administrators group on the local computer to perform these operations.

    Here is a scenario I found where one would use psconfig instead of the MOSS graphical interface.

    For example, if you want to use a SQL server installed on different domain than SharePoint, without using domains trust relationship, you have to connect to the SQL instance using SQL authentication. When creating, or connecting a server to a farm, the only way to use SQL authentication is to use psconfig.exe (located at 12\bin directory) tool.

    More information on psconfig.exe:http://technet.microsoft.com/en-us/library/cc263093.aspx.

    You can also refer to :http://blogs.msdn.com/yvan_duhamel/archive/2008/11/24/configuring-your-sharepoint-farm-through-psconfig-command-line-tool.aspx


    Tuesday, August 25, 2009

    Excel Services error: You do not have permissions to open this file



    I was configuring Excel Services and got this error

    The following steps helped me get rid of it:

    1. Open Central Administration -> go to Operations tab
    - ensure that the Excel Service is running

    2. Open Central Administration -> go to your configured Shared Service -> click Excel Service Settings
    - File Access Method: ensure that it is not using Impersonation, instead the Option Process Account should be enabled.

    3. Open Central Administration -> go to your configured Shared Service -> click add new trusted file location
    - field URL: here you can specify a report library or the whole portal
    - Location Type: should be Windows SharePoint Services
    - Children trusted: defines whether the children should also be trusted or only the definied path

    I had spaces in my doc lib name so I tried adding only the top site name and having its children trusted..it worked for me

    Monday, August 24, 2009

    MOSS 2007 :Feature Stapling

    A very interesting concept I came across is Feature Stapling.MSDN explains it as:

    In Windows SharePoint Services 2.0, many of the customizations that organizations wanted required changes to the built-in site definitions. These types of customization were not supported by Microsoft because these files may need to be replaced by future service packs. To work around this limitation with the site definitions, you would copy the built-in definitions, make the required customizations, and hide the original definitions from the end user. This process would ensure that a service pack would not break the site definition.
    In SharePoint Server 2007, Features enable you to turn functionality on and off within a site, even if the functionality was not in the original site definition. Although modifying the built-in site definitions is still not advisable or supported, you can use a process named Feature Stapling to attach a Feature to a site definition without modifying it in any way. For example, you can use this process to attach your custom application to the built-in definition.

    For more refer:
    http://msdn.microsoft.com/en-us/library/bb954662.aspx
    http://blogs.msdn.com/cjohnson/archive/2006/11/01/feature-stapling-in-wss-v3.aspx

    http://blogs.msdn.com/sharepoint/archive/2007/03/22/customizing-moss-2007-my-sites-within-the-enterprise.aspx

    Thursday, August 20, 2009

    MOSS 2007 : BDC Search

    Searching on Business Data once you configure the BDC is easy. Here are a few good links explaining how one could configure search on Business Data and create custom scopes.
    http://msdn.microsoft.com/en-us/library/ms584031.aspx
    http://msdn.microsoft.com/en-us/library/bb410114.aspx

    Wednesday, August 19, 2009

    MOSS :Using BDC data in a list

    An excellent article that directs in adding bdc data to a list is as below:
    http://msdn.microsoft.com/en-us/library/ms548808.aspx

    BDC Metadata for SQL Server 2000 Adventure Works db

    BDC Metadata for SQL Server 2000 Adventure Works db Here is the metadata for SQL Server 2000 Adv Works DB.I searched a lot for Adv Works 2005 metadata but the msdn samples for 2005 have very elementary stuff in there without filters etc.I needed something a bit more complex and with the tables named product ,customer etc and not dimproduct or dimcustomer.Most sample metadata has the latter tables and I can't find a similar adv works 2000 db. Finally I found this metadata in a msdn link which does work with the current Adv Works Cycles 2000 db.You can download the sample db from the following link: http://www.microsoft.com/downloads/details.aspx?FamilyID=487C9C23-2356-436E-94A8-2BFB66F0ABDC&displaylang=en
    The metdata is as in the link below:Note the mode of authentication that worked for me is RevertToSelf.
    The only thing you need to add below is your server name as indicated in the tag.
    http://msdn.microsoft.com/en-us/library/ms497572.aspx

    Hope it works for everyone...working with the BDC is a true test of patience :)

    Wednesday, August 12, 2009

    SharePoint :Advantages of Data Connection Libraries

    The Data Connection Library (DCL) is a new type of document library in Microsoft Office SharePoint Server 2007 that allows applications such as Microsoft Office InfoPath 2007 and technologies like Excel Services to specify data connection settings using external files. This provides several advantages:

    • Reconfiguration: Data connection settings, such as database server locations, can be modified independently of the solutions that use them.

    • Deployment to Different Environments: Test and production servers can specify different locations for data access and a form template will automatically use the server-specific location when published to that server.

    • Authentication: Using Office Single Sign-On, server administrators can specify alternative authentication credentials to be used by the server when processing a form for the browser.

    • Cross-domain security: The Data Connection Library (DCL) serves as a "safelist" for data connections. For forms that are not published with full-trust, only connections specified using the DCL can retrieve data from outside the farm.

    Tuesday, August 11, 2009

    Sharepoint BDC error:Unable to connect to AdventureWorks,NT AUTHORITY\ANONYMOUS LOGON

    I have done a lot of stuff with the BDC in MOSS and everytime I work with it I get a new error ;) I was trying a simple connection to Adventure Works 2005 database which was on a different server.I could connect using the BDC Definition Editor and could retrieve data but when I added a BDC webpart to my SharePoint page , I got "Unable to connect to Adventure Works".It clearly was an authentication issue but I had to track it.Here are the steps I used :
    • I went on to check the SharePoint logs which are stored in:"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Logs" I opened the latest log and searched for "Business Data". There were loads of records.So I thought let me do my own Logging.
    • So I went on to 'Central Administration' -> 'Operations' -> 'Diagnostic Logging' -> 'Event Throttling' and turn on the objects that I wanted to monitor. In this case, I wanted to turn on 'Business Data', select 'None' and 'Verbose'. I also customized my log path so that it was not as long as the default value.
    • Now when I tried connecting the webpart again to my application definition I got the error on my log file "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'"
    • So now I went on and opened my application definition file and changed the authentication type from "PassThough" to "RevertToSelf" authentication and VOILA !! IT WORKED :)


    Monday, August 10, 2009

    MOSS 2007:List of backup and recovery tools

    Here is the list of backup and recovery options to help you decide when and what options you can use:
    http://technet.microsoft.com/en-us/library/cc287880.aspx

    This article however doesnt mention The SharePoint Designer backup and recovery which is very useful in backing up and restoring almost all levels of MOSS sites(farm,web app,site collectio,subsites) ,mostlysubsites and in also performing backup and restore when one doesnt have direct access to the production server

    Thursday, August 6, 2009

    Wednesday, August 5, 2009

    MOSS Taxonomy and benefits :An excellent article

    The following is an article that i found in an excellent blog detailing the beneifts of developing a strong corporate taxonomy as part of a SharePoint 2007 implementation. Hopefully you will find it useful.
    Here is the link to the article of which I too have an extract below:

    http://joeshepherd.spaces.live.com/Blog/cns!9AE2097A4A610B63!120.entry

    The case for a Taxonomy
    Understanding the benefits:
    Developing a metadata taxonomy is a core step in defining an effective SharePoint 2007 deployment that will be readily accepted by your customer base. This process consists of categorizing the content of your sites and deciding on how users will locate that content. SharePoint offers several key features that make business more flexible and efficient and a solid taxonomy is the foundation that each of these features are built upon. While these features will work without a well formed taxonomy, the existence of even the most simplistic taxonomy can greatly increase their effectiveness. A brief list of features and how they benefit from a taxonomy is detailed below.

    • Content Types
      SharePoint 2007 offers a feature known as a Content Type that can be defined by site and site collection administrators. Content Types are wrappers of MetaData that are created around any set of core content types that exist inside the “out – of – box” SharePoint deployment. These core content types are a Word Document and an InfoPath Form. Administrators can extend these core types and use them to create new custom content types within SharePoint. Administrators specify the MetaData that is associated with the new content type along with any workflows or templates that may be required.
      For example, an administrator can create a custom Content Type of Policy that is based on a word document. That content type could then have certain attributes associated with it such as “Association” that specifies weather this policy applies to a specific department or to the entire organization. Custom workflows could also be attached to this Policy that sends out notifications upon changes to everyone who has an interest in the policy.
      These MetaData attributes provide the greatest functionality if they can be tied back to a larger corporate taxonomy that lays the ground work for defining that MetaData. Content types are a powerful feature in SharePoint 2007 but in order to use them to their potential you must first develop a comprehensive plan on how to categorize your information. Doing so allows you to hone in on those attributes that provide the greatest flexibility and power.
    • Navigation
      Navigation is one benefit of a well thought out taxonomy since it dictates how users navigate the site and its various sub-sites in search of content. Most organizations will opt for a hierarchical taxonomy in this area that closely mimics their organizational structure. This allows for a navigational structure that the user is familiar with.
      For document repositories, such as the document center, navigation based on the taxonomy is important because it allows users to get to the information that they are looking for in a timely manner. If the user is looking for a project request form, the best scenario would be to have that form exist in a Forms library inside the document center. All forms in the organization would exist inside this library that could be further segregated by departments or any other lower level category. A taxonomy will help drive out these requirements up front in the planning stage when changes can me made with little to no cost impact.
    • Search and Indexing
      By effectively leveraging content types that extend a well formed taxonomy, search results can be tailored to specific audiences within SharePoint. This feature will allow administrators to provide targeted search results based upon MetaData attributes for specific users. For instance if a user in accounting performs a search on Policies SharePoint can serve up a subset of that search result that is targeted only to personnel in the accounting department; thus returning only accounting specific policies. The Search mechanism works in tandem with the Content Types to leverage that MetaData derived from the taxonomy.
    • Audience Targeting
      Just as search results can be targeted based on audiences so can content within the individual SharePoint sites themselves. This creates the ability to intermingle content in the accounting site and specify that that content only be visible to individuals in the accounting department. This provides an abstract layer of security at the site level that would otherwise have to be configured via roles and access permissions. Once again this capability is largely driven off the effective use of Content Types and those MetaData attributes.
    • Information Categorization and Retrieval
      Just as you would organize the documents in your filing cabinet so should you take the time to develop a consistent classification system for the content of your SharePoint sites. Going through the work of establishing a solid taxonomy and MetaData system now will allow you to organize your information into categories that afford users the ability to rapidly locate any information or content they need. The taxonomy helps to ensure that everyone thinks about each item of content the same way. It provides a consistent way of classifying and describing content and information. It also allows you to ensure that the content is stored on the correct place, it is made available to the correct people and that it is managed in a manner that is consistent with that type of content.

    Tuesday, August 4, 2009

    Debugging custom SharePoint applications

    I got an excellent article which outlines common debugging issues and their solutions.Here it goes:

    First thing you need to do to avoid the old fashioned trial and error technique is to enable debugging. This could be achieved by setting the compilation element debug attribute to true in Web.Config from the virtual directory containing your SharePoint application, otherwise, breakpoints inside Visual Studio will be shown but will never be used.
    Once you’ve done that, there is one more thing you need to do in order to be able to debug your SharePoint code in Visual studio which is attaching a debugger to W3WP.EXE, Attaching a debugger in Visual Studio will allow you to step through the code and find exactly where the error occurs.




























    It’s really handy but there are three questions that I always receive from my colleagues when they get started to SharePoint programming, so I decided to share the answers with you.
    The first one is: Sometimes, I set breakpoints and attach to the process but Visual Studio skips loading the symbols if I’m debugging a deployed assembly to the GAC and I fail to debug the code
    Easy, Open Tools -> Options -> Debugging.
    You’ll find an option labeled Enable Just My Code (Managed Only) as shown in the figure which is checked by default. Uncheck this option to be able to debug the assemblies located in the GAC.

    There is a common myth among .NET developers in general and especially SharePoint ones, that in order to debug assemblies that have been deployed to the GAC, you need to copy the debug symbols (PDB File) to the GAC as well. This was true in the early days of .NET but this is no longer true. The second one is: When I try to attach the debugger to the W3WP.exe process to debug, I always see multiple instances of it. Which one should I attach to?
    Ok, this is easy too. Just follow the following steps.
    Open the command prompt window, run IISAPP to get a list of the current instances of W3WP.exe.

    Note the PID of the instance that corresponds to your web application.

    Now return to VS, select Debug -> Attach to process and attach to the W3wp.exe instance with an ID equivalent to the PID you got in step 2 -> click Attach.
    Now you can trace through the code and find the error causes easily.
    But the question still remains, why sometimes are they more than one w3wp.exe instance? This is because the SharePoint Administration Site Collection and the SSP Administration site always have their own Application pools for error isolation purposes.

    And the third question is : Is it possible to debug Inline code blocks ?
    Actually, I hate Inline Code Blocks and it’s really a good practice to avoid it due to the performance issues when the JIT compiler compiles them but YES, you can do that.
    So now you knew the process of debugging? Very boring and repetitive huh? Hmm, Can’t that be automated?Fortunately Jonathan Dibble, a brilliant developer, created a very handy “
    Debugger Feature” that can be installed and activated on a SharePoint site to automate this process. Once activated, the Debugger Feature adds an “Attach Debugger” menu item to the Site Actions menu. Extremely helpful and faster than doing that from visual studio.

    To read the complete article go on to:http://sharepointmagazine.net/technical/development/getting-started-with-sharepoint-programming-simplifying-sharepoint-debugging-by-creating-the-troubleshooting-toolbox

    Happy Debugging :)





    Monday, August 3, 2009

    How to write to Event Log using visual C#

    Write to an event log
    Event logging provides a standard, centralized way for your applications to record important software and hardware events. Windows supplies a standard user interface for viewing the logs, the Event Viewer. By using the common language's run-time EventLog component, you can connect to existing event logs easily, on both local and remote computers, and write entries to these logs. You can also read entries from existing logs and create your own custom event logs. In its simplest form, writing to an event log involves only a few steps to create a sample application. To do this, follow these steps:
    • Open Visual Studio C#.
    • Create a new Console application in Visual C#.
    • The Console application creates a public class and an empty Main method for you.
    • Verify that the project references at least the System.dll file.
    • Use the using directive on the System and System.Diagnostics namespaces so that you do not have to qualify declarations from these namespaces later in your code.

    You must use these statements before any other declarations.

    using System;

    using System.Diagnostics;
    To write to an event log, you must have several pieces of information:

    Your message, the name of the log you to which you want to write (which will be created if it does not already exist), and a string that represents the source of the event.

    You can register a particular source with only a single event log; if you want to write messages to more than one log, you must define multiple sources.

    string sSource;

    string sLog;

    string sEvent;

    sSource = "dotNET Sample App";

    sLog = "Application";

    sEvent = "Sample Event";
    Use two static methods of the EventLog class to check whether your source exists, and then, if the source does not exist, to create this source that is associated with a particular event log.

    If the log name that you specify does not exist, the name is created automatically when you write your first entry to the log.

    By default, if you do not supply a log name to the CreateEventSource method, the log file is named "Application Log."

    if (!EventLog.SourceExists(sSource))EventLog.CreateEventSource(sSource,sLog);


    To write a message to an event log, you can use the EventLog.WriteEntry static method.

    This method has several different overloaded versions.

    The following sample code shows the simplest method, which takes a source string and your message, and one of the more complex methods, which supports specifying the event ID and event type:

    EventLog.WriteEntry(sSource,sEvent);

    EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
    Save your application.

    Run your application, and then check the Application log in the Event Viewer to see your new events.

    Complete code

    using System;

    using System.Diagnostics;

    namespace WriteToAnEventLog_csharp

    {

    /// Summary description for Class1.class

    Class1{static void Main(string[] args)

    {

    string sSource;

    string sLog;

    string sEvent;

    sSource = "dotNET Sample App";

    sLog = "Application";

    sEvent = "Sample Event";

    if (!EventLog.SourceExists(sSource))

    EventLog.CreateEventSource(sSource,sLog);EventLog.WriteEntry(sSource,sEvent);

    EventLog.WriteEntry(sSource, sEvent,EventLogEntryType.Warning, 234);}}}

    MOSS 2007 ebooks

    Thursday, July 30, 2009

    Create a feature to add custom menu item in Site Actions


    Below are the steps I followed to create a custom menu item for the Site Actions Menu on the MOSS 2007 portal.
    I went on to create this and it is very simple.Just follow the steps below: http://www.sharemuch.com/2009/04/17/adding-custom-context-menu-items-to-sharepoint-list-or-library/


    http://blog.rafelo.com/2008/06/how-to-add-menu-items-to-sharepoint.html


    http://msdn.microsoft.com/en-us/library/bb418728.aspx

    Custom Feature in MOSS and its uses

    What and Why Custom Features

    • Features in Microsoft Office SharePoint Server 2007 allow you to easily package up functionality that can be deployed and installed across the server farm. This article walks you through the steps of creating and installing a custom Feature.

    • Features are a major enhancement to the template framework of Microsoft Office SharePoint Server 2007 (MOSS). Features allow you to test, deploy, and activate custom functionality inside Office SharePoint Server 2007 and provide a way to make functionality available across your server farm. This functionality can be custom workflows, content types, modifications to the user interface, or new templates for lists and document libraries. For example, you can roll out the definition of a custom document library to any number of team sites by packaging it up as a Feature, complete with metadata expressed in the Collaborative Markup Language (CAML) in the schema. You can package the Feature up as a SharePoint solution and provide it to an administrator, where it can be installed and deployed as a unit.

    • Another benefit of using Features is in the use of site definition (ONET.xml) files. ONET.xml files provide Windows SharePoint Services with information about the navigation, lists, and document libraries that users can create. In the previous version of SharePoint, ONET.xml files have a tendency to get very large. With the advent of Features, the ONET.xml file shrinks because Features can now contain the information that was previously defined in the ONET.xml file.
    • Features provide a level of reusability by providing you with a means to package and deploy functionality as a unit. You can install the Feature at the level of a server farm and then active it only when needed. This has the additional benefits of allowing you to deploy updates to all Web front-end machines in one operation, more easily applying source-control to site resources, and allowing less-technical people to roll-out or roll-back changes, if required.

    Exploring the Components of a Feature

    Features are typically stored on the SharePoint server at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES. Each Feature has its own sub-directory that resides in this directory. Inside each Feature's sub-directory, you will find, as a minimum, a header file named feature.xml. The feature.xml file points to a manifest file that tells SharePoint where to find the code and XML that defines the Feature. The feature.xml file contains the Feature element that specifies the location of assemblies, files, dependencies, or properties that support the Feature. Optionally, the Feature element may point to an XML file that contains an Element element which defines the components and types that make up the Feature.

    SSP in MOSS

    SSP

    In MOSS 2007 there is this new concept of Shared Services Providers(SSP). The idea being that there are certain services that really make sense to centrally manage and share. A good example being profiles. With a SSP we can import all of the profile information from AD once and then our various web applications can consume the data. So maybe we have http://marketing and http://accounting it doesn't make sense for each one to maintain identical profile information, they should share.

    The major services that are handled by the SSP are:

    • Profiles and Audiences
    • My Sites
    • Search
    • All of Excel Services
    • All of the BDC (Business Data Catalog)

    Below is an example screen shot from MOSS 2007 Enterprise:

    Wednesday, July 29, 2009

    Switch Views in InfoPath

    An easy way to switch views in InfoPath 2007 is the following:
    Go to Tools --> FormOptions --> Open and Save -->Click on Rules-->Add a Rule -->Set Condition -->Add Action
    Here you will see an action called Switch Views.
    From here you can toggle views of InfoPath

    SSRS in a nutshell

    What is SQL Server 2005 Reporting Services?

    SQL Server 2005 Reporting Services (SSRS) is a robust reporting solution that runs on Microsoft Internet Information Services (IIS) on Microsoft Windows® XP, Windows 2000, and Windows Server™ 2003. It works with data that resides on the SQL Server 2005 platform, as well as other data sources. SSRS can deliver reports in a variety of formats. The reports can be delivered on paper or through interactive Web-based reports.

    SQL Server Reporting Services supports the full reporting life cycle, including:

    • Report authoring. Report developers can create reports to be published to the report server by using design tools that use Report Definition Language (RDL), an XML-based industry standard used to define reports.

    • Report management. Report definitions, folders, and resources are published and managed as a Web service. Managed reports can be executed either on demand or on a specified schedule, and are cached for consistency and performance.

    • Report delivery. SQL Server Reporting Services supports both on-demand (pull) and event-based (push) delivery of reports. Users can view reports in a Web-based format or in e-mail.

    • Report security. SQL Server Reporting Services implements a flexible, role-based security model to protect reports and reporting resources. The product includes extensible interfaces for integrating other security models as well.