Follow in Twitter & Facebook


Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools


Tuesday, May 29, 2012

Programtically send email in SharePoint 2010

- No comments
In this article we will discuss how to send email programmatically in SharePoint 2010 by using SharePoint Object model.

SPUtility class is used to send email programatically. This class will be avilable in namespace
using Microsoft.SharePoint.Utilities;
Here is the code sample to send email:

using Microsoft.SharePoint;
using  Microsoft.SharePoint.Utilities; 

void
{
sendMail()SPUtility.SendEmail(SPContext.Current.Web, falsefalse"tomailaddress@sharepointdotnet.com""This is the subject""This is the whole body"); 
}
 
Also you can visit some SharePoint 2010 articles here.
 

Tuesday, May 22, 2012

Extract first N words from a string with C#.Net

- No comments
Here we will describe how to get the first n words of a String using C#.Net. Also you can check an article on String and StringBuilder in C#.Net.

You can extract first N words from a string by converting an array. But here we will discuss how we can do using RegularExpressions like below:

string strWholeString = "String1 String2 String3 String4 String5 String6 String7 String8"
string extractedString = Regex.Match(strWholeString, @"^(\w+\b.*?){5}").ToString();

Here 5 is the number words you want to retrive.
The above regular expression will return "String1 String2 String3 String4 String5";

But we will get exception if the Number of words we are retrieve is less than the total words.

So it is better to retrieve how many words the string contains like below:
We can retrieve the count by using MatchCollection class like below:

MatchCollection collection = Regex.Matches(strWholeString, @"[\S]+");
int count = collection.Count;
string firstWords = Regex.Match(strWholeString, @"^(\w+\b.*?){" + count + "}").ToString();

All the classes with using System.Text.RegularExpressions; Namespace.

Sunday, May 20, 2012

Urgent Openings for SharePoint Developer for our MNC Client

- No comments
Urgent requirement for Sharepoint developer for Our MNC client
SKILL :Sharepoint Developer.
Should have work experience in MOSS 2007 and MOSS 2010.
Notice Period: 10-15 Days,
EXP: 3+yrs

Tuesday, May 15, 2012

Convert ArrayList to String using C#

- No comments
In this C#.Net article we will discuss how to covert an arraylist to a string using C#.Net. You can also check my last article on Arraylist,Hash table,Sorted list and Dictionary C#.Net.

To covert an arraylist to string we can use the built in fuction join of String class. It is an overload method which takes one parameter as the separator and other parameter is the String[] array.
So we need to first convert the arraylist to a string array and then we can use the join method.
Suppose we have an array list like below:

ArrayList arrayList = new ArrayList();
arrayList.Add("First String");

arrayList.Add("Second String");
arrayList.Add(
"Third String");

//Now we can convert the arraylist to string array.
string[] stringArray = (string[])arrayList.ToArray(typeof(string));

//After that we will use the Join method to convert the string array to string. Here the string separator is '|'string finalResult = string.Join("|", stringArray);

So the result will come like below:
First String|Second String|Third String

Saturday, May 12, 2012

Causes of Performance issues in SharePoint 2010

- No comments
In this article we will discuss what are the main reasons of performance issue in SharePoint 2010. We should be very careful while  writing SharePoint Object Model code. Also you can see an article on SPDisposableChecker which is used to analyse weather all objects are disposed properly or not..

Some of the causes below:

- Not disposing properly the SPSite and SPWeb objects after use. You can also check how to dispose SharePoint 2010 objects.

- If you will go for iterating through large items in large list instead of executing queries on the list.

- If you are avoiding SPSiteDataQuery, instead of for each loops to aggregate SharePoint data.
- Using recursive method calls to iterate through information in every site within a site collection.

- If you fail to close external connections after use.

- While connecting to external systems and fails to trap timeouts.

- Another major issue is overuse or improper use of session state.

- Not using of caching like blob caching,Profile caching, Output Caching, Object Caching etc.

Also you can see an article on SharePoint 2010 Best Practices.

Instance Members vs Shared Members in VB.Net

- No comments
Introduction:
Here in this article, we will discuss about Instance Members and Shared Members in VB.Net. Also you can check SQL Server Articles.

Description:
Members of a class in VB.Net are classified into Instance members and Shared members.
Members of the class that can be acessed only by creating an instance for the class called it as a instance members and the members of the class that can be acessed directly by using class name without creating instance are called as Shared Members.
To declare the members as Shared member use the keyword Shared while declaring that member.

Shared member cannot be acessed using an instance and Instance member cannot be acessed by using class name.
For the instance members memory will be allocated when an instance is created by using the keyword new.
But for shared members memory will be allocated while program that contains the class loaded into memory.

Shared Fields:
You can declare the fields avaible in the class as shared, But when the fields are declared as shared then those fields will exist only one copy in memory for any number of instance created for the class.

Main purpose of th Shared field is to store the data i.e to be shared by all instance of the class.

For Example, When you want to maintain a count of how many instances are created for the class upto now then you must create the field as shared.

Shared Methods:



Methods in a class can be declared as shared, but shared methods can acess only other Shared members available in the class and they cannot acess instance members of the class.

The concept in C#.Net i.e equivalent to shared members in VB.Net is Static members. Equivalent to Shared fields  C#.Net  provides static fields and eqivalent to Shared fields  C#.Net provides static fields and equivalent to Shared methods  C#.Net  provides static methods.

C#.net also provides static classes when every member in the class is static then class can be declared as static.
Class can be declared as static so that creating an instance for the class will not be allowed indicating every member in the class is static. But VB.net doesnot provide shared classes.

Static:-
VB.Net provides the keyword static. But in VB.Net static keyword is used like a storage class in C. It can be used in VB.Net only for declaring local variables local variables of methods.

Tuesday, May 8, 2012

Looping control statements in VB.Net

- No comments
Introduction:
Here we will discuss about different looping control statements in VB.Net. Also you can check my articles on SQL Server and Asp.Net.

Description:
There are different looping control statements available in VB.Net. These are

1-While:
Syntax: while <condition>
           <stmts>
         [exit while]
         end while

Monday, May 7, 2012

Asp.Net Job Openings in Bangalore

- No comments
Here is an asp.net openings in bangalore. Job Details below:

Work Location : Bangalore

Company Name : CMMI LEVEL4(Aditya Birla )

Experience : 4 To 6 Years

Working Timing's : 1PM To 11PM

Mode Of Interview : Face To Face(Week Days)

Friday, May 4, 2012

Cannot access a disposed object. Object name:'Form4'

- No comments
Introduction:
Here we will discuss about one ObjectDisposedException, which i got when i was doing one WindowsFormApplication demo using Vb.Net. The Exception was like "Cannot access a disposed object. Object name:'Form4'".

Description:
Here we will discuss about one Exception i.e "Cannot access a disposed object. Object name:'Form4'", which i got while i was doing one Windows Application demo using Vb.Net.In my demo there was one start button, one Stop button, one Progressbar, one Level, one BackgroundWorker.

When i clicked on start button now it was progressing with the percentage of progressing. With in that i clicked the Stop button then i saw the cancelled message. Then when i again clicked on the Start button , i found that Exception i.e "Cannot access a disposed object. Object name:'Form4'".

I got the error in this line like SetLabelText_ThreadSafe(Me.lbl_Status, FormatPercent(i / m_CountTo, 2)).

For the solution of this exception you need to check first the 'IsDisposed' property of the control before acessing the control.

Otherwise you need to instanciate the form inside the constructor of that form.
Dim frm4 As New Form4()

The screenshot of that Exception, I am sharing now.....

Thursday, May 3, 2012

BackgroundWorker Control in C#.NET

- No comments
Introduction:
Here in this article, we will discuss about Backgroundworker control in C#.NET. How it exactly helps us for running our applications.

Description:
If we are going to use multithreaded applications, then we can able to do many time consuming tasks asynchronously.

Backgroundworkers make threads easy to implement in windows forms. So in case of Intensive tasks need to be done on another thread so that the UI doesn't freeze. This is our main aim that the UI doesn't freeze.

Wednesday, May 2, 2012

Objectreference not set to an instance of an object.

- No comments
Introduction:
Here we will discuss about one NullReferenceException Which i got while doing one Demo using Vb.Net. The exception was like "Objectreference not set to an instance of an object".

Description:
I got one EXception while doing one windows Application demo in Vb.Net.This Exception was nothing but one NullReferenceException. The Exception was like "Objectreference not set to an instance of an object".

At that time my code was like below:

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
      ByVal e As System.ComponentModel.DoWorkEventArgs) _
      Handles BackgroundWorker1.DoWork
        ' Do some time-consuming work on this thread.
        System.Threading.Thread.Sleep(1000)
        ' Get argument.
        Dim args As ArgumentType = e.Argument
      
        ' Return value based on the argument.
        e.Result = args._a * args._b
    End Sub

So i was searching for the solution, Finally i used the new keyword to instanciate that one.
Insteadof Dim args As ArgumentType = e.Argument  ,i wrote  Dim args As ArgumentType = New ArgumentType().
Now my code looks like that as below:

 Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
      ByVal e As System.ComponentModel.DoWorkEventArgs) _
      Handles BackgroundWorker1.DoWork
        ' Do some time-consuming work on this thread.
        System.Threading.Thread.Sleep(1000)
        ' Get argument.
        Dim args As ArgumentType = New ArgumentType()
      
        ' Return value based on the argument.
        e.Result = args._a * args._b
    End Sub
so Now there is no error...

I am sharing the screenshot as below....


Also you can see some SQL Server and Asp.Net articles.