Sunday, February 13, 2011

How To Write Exception error In Sharepoint Log File

Add Microsoft.Office.Server dll in your project, you can find this dll under “\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\”.

The log files are found under \Common Files\Microsoft Shared\Web Server Extensions\12\Log\. Following line of code is used to write exception in sharepoint default log file.

Microsoft.Office.Server.Diagnostic.PortalLog.LogString(“Exception – {0} – {1} – {2}”,”Log Message”,ex.Message,ex.StackTrace);

Wednesday, February 9, 2011

Disable SharePoint DataTime Control Event

((TextBox)(dtduedate.Controls[0])).Attributes.Add("onKeyPress", "DisbleEnterKey();");

Saturday, February 5, 2011

SharePoint DateTime control returning current date when no date is selected

In WSS 3.0/4.0, I am using sharePoint DateTime control. I retrieve the date selected by the user using SelectedDate property of the sharePoint DateTime control.

The issue is that even when the user has not selected any date in the sharePoint DateTime control, the SelectedDate property of the sharePoint DateTime control returns current date.

Solution :

if (dt.IsDateEmpty)
{
objdt = DBNull.Value;
}
else
{
objdt = dt.SelectedDate.ToString();
}

Tuesday, December 28, 2010

Parser Error in sharepoint


Today I have faced parser error in SharePoint when someone has changed compat.browser file in
SharePoint designer.

After searching in Google, I found that some of file App_Browsers folder was corrupted. I have deleted file from folder and reset IIS. My site is working fine.





Saturday, December 4, 2010

SharePoint search using FullTextSqlQuery

//SharedServices2 refers to the Shared Service Provider servicing
ServerContext context = ServerContext.GetContext("SharedServices2");
FullTextSqlQuery qrySearch = new FullTextSqlQuery(context);
//Specifies the results set containing the main search results from
//the content index matching the search query.
qrySearch.ResultTypes = ResultType.RelevantResults;
//Sremming : expansion of searches to include plural forms and
//other word variations :-)
qrySearch.EnableStemming = true;
qrySearch.TrimDuplicates = false;
qrySearch.QueryText = "SELECT URL, Title, Size, Write, HitHighlightedSummary FROM SCOPE() where \"scope\"='NTFS Archive' And FREETEXT(*,'" + TextBox1.Text.Trim() +
"')";
ResultTableCollection results = qrySearch.Execute();
ResultTable resultTable = results[ResultType.RelevantResults];
// Data Table to Store Search Results
DataTable dtResults = new DataTable();
dtResults.Load(resultTable, LoadOption.OverwriteChanges);