Wednesday, December 29, 2010

LinkButton in SharePoint - Not firing Click Event

1. General way
imageButton.OnClientClick = "this.form.onsubmit = function() {return true;}";
or
hyperLink.OnClientClick = "this.form.onsubmit = function() {return true;}";
or
linkButton.OnClientClick = "document.getElementsByTagName(\'form\')[0].onsubmit = function() {return true;}";


2.In SharePoint
linkButton.OnClientClick = "_spFormOnSubmitCalled = false;_spSuppressFormOnSubmitWrapper=true;";


Reference Link::  
http://dev-tips.blogspot.com/2009/12/linkbutton-in-sharepoint-not-firing.html

Thursday, December 23, 2010

Tuesday, November 23, 2010

Facebook Developer Kit

Please refer the following link if you want to integrate the Facebook controls in your windows as well as web applications.


To download the Facebook developer kit use the following URL.


http://www.microsoft.com/downloads/en/details.aspx?FamilyID=CCD46762-45EC-4FBE-AD91-FC916671E734&displaylang=en


And to integrate the Facebook controls in your applications use the following URL.


http://www.stevetrefethen.com/blog/DevelopingFacebookApplicationsInCWithASPNET.aspx


Use the following URL to put the Like button of the Facebook in your applications.


http://developers.facebook.com/docs/reference/plugins/like-box

Thursday, November 11, 2010

Formatting Dates, Times and Numbers in ASP.NET

Please check the following link to format the dates,numbers and Time in Asp.Net.

Thursday, November 4, 2010

File upload content types

If we are uploading the file and if we want to know the exact extension of the file then, please use the following code.


public bool GetActualFileType(Stream stream)
        {
            try
            {
                using (System.IO.BinaryReader sr = new System.IO.BinaryReader(stream))
                {
                    byte[] header = new byte[16];
                    sr.Read(header, 0, 16);


                    StringBuilder hexString = new StringBuilder(header.Length);
                    for (int i = 0; i < header.Length; i++)
                    {
                        hexString.Append(header[i].ToString("X2"));
                    }


                    string FileTypeCode = GetFileTypeByCode(hexString.ToString());
                    if (FileTypeCode == "undefined")
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        private string GetFileTypeByCode(string code)
        {
            Dictionary fileheadlist = new Dictionary();
            fileheadlist.Add(".xls", "D0CF11E0A1B11AE10000000000000000");
            fileheadlist.Add(".xlsx", "504B0304140006000800000021005856");
            fileheadlist.Add(".doc", "D0CF11E0A1B11AE10000000000000000");
            fileheadlist.Add(".docx", "504B030414000600080000002100DDFC");
            fileheadlist.Add(".ppt", "D0CF11E0A1B11AE10000000000000000");
            fileheadlist.Add(".pptx", "504B03041400060008000000210036F7");
            fileheadlist.Add(".avi", "41564920");
            fileheadlist.Add(".ram", "2E7261FD");
            fileheadlist.Add(".rm", "2E524D46");
            fileheadlist.Add(".mpg", "000001BA");
            fileheadlist.Add("MPEG(.mpg)", "000001B3");
            fileheadlist.Add(".mov", "6D6F6F76");
            fileheadlist.Add(".asf", "3026B2758E66CF11");
            fileheadlist.Add(".MP4", "000000206674797069736F6D");
            fileheadlist.Add(".mp3", "49443303000000050F76545045320000");
            fileheadlist.Add(".pdf", "255044462D312E");


            fileheadlist.Add("GIF", "47494638");
            fileheadlist.Add("PNG", "89504E47");
            fileheadlist.Add("JPEG", "FFD8FF");
            fileheadlist.Add("TIFF", "49492A00");
            fileheadlist.Add("Windows Bitmap (bmp)", "424D");
            fileheadlist.Add("CAD (dwg)", "41433130");
            fileheadlist.Add("Adobe Photoshop (psd)", "38425053");
            fileheadlist.Add("Rich Text Format (rtf)", "7B5C727466");
            fileheadlist.Add("XML (xml)", "3C3F786D6C");
            fileheadlist.Add("HTML (html)", "68746D6C3E");
            fileheadlist.Add("Email [thorough only](eml)", "44656C69766572792D646174653A");
            fileheadlist.Add("Outlook Express (dbx)", "CFAD12FEC5FD746F");
            fileheadlist.Add("Outlook (pst)", "2142444E");
            fileheadlist.Add("MS Access (mdb)", "5374616E64617264204A");
            fileheadlist.Add("WordPerfect (wpd)", "FF575043");
            fileheadlist.Add("Postscript. (eps.or.ps)", "252150532D41646F6265");
            fileheadlist.Add("Quicken (qdf)", "AC9EBD8F");
            fileheadlist.Add("ZIP Archive (zip)", "504B0304");
            fileheadlist.Add("RAR Archive (rar)", "52617221");
            fileheadlist.Add("Wave (wav)", "57415645");
            fileheadlist.Add("MIDI (mid)", "4D546864");
            fileheadlist.Add("3GP", "000000146674797033677034");




            var vals = from p in fileheadlist
                       where code.StartsWith(p.Value)
                       select p;
            KeyValuePair result = vals.First();
            foreach (var i in vals)
            {
                if (i.Value.Length > result.Value.Length)
                {
                    result = i;
                }
            }
            return result.Key ?? "other";
        }




Courtesy: http://forums.asp.net/p/1554764/3829152.aspx

Monday, October 25, 2010

Sending multiple rows to the Database from an Application in XML Format

If the XML data is in the form 






then the pass the  xml data to the stored procedure and the procedure will parse the xml and inserts the data into the database as written below in the stored procedure.


Create a table called Employee Having the following fields.
employeeId(int),Name(varchar(50)),salary(money),
designation(varchar(50)),department(varchar(50)) and 


write the procedure as below.



Create Procedure InsertData
(
@xml XML
)
as
BEGIN
Insert INTO Employee(employeeId,Name,salary,designation,department)
SELECT T.Item.value('@EmployeeId', 'Int') EmployeeId,
  T.Item.value('@Name', 'VARCHAR(50)') Name,   T.Item.value('@salary', 'Money') salary,   T.Item.value('@designation', 'VARCHAR(50)') designation,   T.Item.value('@department', 'VArchar(50)') department  
 FROM @xml.nodes('/ROWS/ROW') AS T(Item)
END



This will parse the XML Data passed and will insert the values into the database.


Please refer to the following link.





http://www.sqlservercentral.com/articles/T-SQL/67603/

Thursday, October 21, 2010

How to assign strong name to an external DLL

Open Visual Studio command prompt.
For this you must have a strong name key file(.snk file)


ildasm dllname.dll /OUT=dllname.il
ilasm /DLL dllname.il /KEY=keyname.snk

How to use the command prompt to open a Remote Desktop Connection(RDP)

Please use the following command for opening the remote desktop in command prompt.
mstsc /admin /v:ServerName

Friday, August 27, 2010

Parsing Two Arrays in a Stored Procedure OR Nested While Loops in stored Procedure


This Stored procedure receives two arrays and it parses two arrays and inserts the record in the database.
This uses Nested while loops to parse two arrays.

CREATE PROCEDURE ParseArray (@Array VARCHAR(1000),@Array1 VARCHAR(1000),@separator CHAR(1))
AS

BEGIN
SET NOCOUNT ON

-- @Array is the array we wish to parse
-- @Separator is the separator charactor such as a comma
        Declare @TempArray VARCHAR(1000)
        SET @TempArray=@Array1
        Declare @ArrayCount INT
        SET @ArrayCount=LEN(@Array1)
       
        DECLARE @separator_position INT -- This is used to locate each separator character
        DECLARE @array_value VARCHAR(1000) -- this holds each array value as it is returned
       
        DECLARE @separator_position1 INT -- This is used to locate each separator character
        DECLARE @array_value1 VARCHAR(1000) -- this holds each array value as it is returned
-- For my loop to work I need an extra separator at the end. I always look to the
-- left of the separator character for each array value

        SET @Array = @Array + @separator
        -- Loop through the string searching for separtor characters
        WHILE PATINDEX('%' + @separator + '%', @Array) <> 0
            BEGIN
                -- patindex matches the a pattern against a string
                SELECT  @separator_position = PATINDEX('%' + @separator + '%',@Array)
                SELECT  @array_value = LEFT(@Array, @separator_position - 1)               
                -- This is where you process the values passed.
                -- Replace this select statement with your processing
                -- @array_value holds the value of this element of the array
               -- SELECT  Array_Value = @array_value
                SELECT  @Array = STUFF(@Array, 1, @separator_position, '')
                if @ArrayCount = 0
                    BEGIN
                        SET @Array1 = @TempArray + @separator
                    END
                ELSE
                    BEGIn
                        SET @Array1 = @Array1 + @separator                       
                    END
               
                WHILE PATINDEX('%'+@separator+'%',@Array1)<>0
                    BEGIN
                        -- patindex matches the a pattern against a string
                        SELECT  @separator_position1 = PATINDEX('%' + @separator + '%',@Array1)
                        SELECT  @array_value1 = LEFT(@Array1, @separator_position1 - 1)
                        --print @separator_position
                       
                        print 'val1='+@array_value+ ' val2='+  @array_value1
                        -- This is where you process the values passed.
                        -- Replace this select statement with your processing
                        -- @array_value holds the value of this element of the array
                        --SELECT  Array_Value1 = @array_value1
                        SELECT  @Array1 = STUFF(@Array1, 1, @separator_position1, '') 
                        SET @ArrayCount= LEN(@Array1)                       
                        Insert Into Test(i1,i2) Values(@array_value,@array_value1)
                        print @Array1
                    END
                               
                -- This replaces what we just processed with and empty string               
            END
SET NOCOUNT OFF
END






Happy Coding.....!!!!!  :)

Thursday, July 15, 2010

A file in SharePoint Designer is Checked Out, But it is not --> Problem with SharePoint Designer

In sharepoint designer, some times some files will look like they are checked out. But if you try to check in the files, then it will not allow you to check in, because they have not check out. This is the problem in sharepoint designer. It will not allow you to check out the file also.


To resolve this issue, Go to C:\Users\[User name]\App Data\Local\Microsoft\WebSiteCache,


and delete the chached data present in that folder. And then restart the SPD and try to check in the files, it will display you the error message, but the problem will be resolved.


Thanks to the blogs

http://blog.drisgill.com/2009/08/sharepoint-designer-wrongfully-says.html
http://www.tompuleo.com/2009/04/sharepoint-designer-says-i-have-file.html

IE Error in Sharepoint "Library Not Registered"

While I am using the sharepoint pages in IE 7, I got the following error "Library Not Registered", when I tried to add a image into the article page.


I resolved this error by running Microsoft Office Diagnostics tool. 

Integrating ASP.NET AJAX with SharePoint

http://blogs.msdn.com/b/sharepoint/archive/2007/03/02/integrating-asp-net-ajax-with-sharepoint.aspx

Programatically Adding WebPart to SharePoint Page and SharePoint WebPart Gallery.

http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=70


http://neganov.blogspot.com/2007/11/add-web-part-to-sharepoint-page.html

Tuesday, June 29, 2010

Ghostable vs GhostInLibrary

http://www.sharepoint4arabs.com/AymanElHattab/Lists/Posts/Post.aspx?ID=97


http://gvaro.spaces.live.com/blog/cns!B06529FD3FC75473!855.entry

Code which will accept the date in dd/mm/yyyy format and return in the mm/dd/yyyy format in C#

string strFormatted = "";
DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo;
dateTimeFormatterProvider.ShortDatePattern = "dd/MM/yyyy"; //source date format
DateTime dateTime = DateTime.Parse(strDate, dateTimeFormatterProvider);
strFormatted = dateTime.ToString("MM/dd/yyyy");
return strFormatted;

Monday, June 28, 2010

Command to create the Configuration Database and Admin Content Database while installing MOSS 2007

Go to 


C:\\Program Files\Common Files\microsoft shared\web server extensions\12\bin


and use the following command.


psconfig -cmd create -servername sqlserver -database SharePoint_Config
-dbuser sa -dbpass sapassword -user sqlservices -password
sqlservicespassword -admincontentdatabase Admin_Content

Upload Files in SharePoint 2007

http://www.eggheadcafe.com/community/aspnet/69/10138586/uploading-picture-in-pict.aspx


http://www.dotnetspider.com/resources/29565-Uploading-images-into-picture-library.aspx


http://stackoverflow.com/questions/468469/how-do-you-upload-a-file-to-a-document-library-in-sharepoint


http://elczara.spaces.live.com/blog/cns!554EC06D366AC9D5!692.entry

Workflow Activities MOSS 2007

http://geekswithblogs.net/stephaniegrima/archive/2008/09/26/sharepoint-workflow-activities---what-are-they.aspx


http://covelle.blogspot.com/2006/06/add-sharepoint-workflow-activities-to.html

Windows Workflow Foundation MOSS 2007

http://msdn.microsoft.com/en-us/library/aa830816(office.12).aspx#office2007ssintrotoworkflows__workflowcomposition


http://channel9.msdn.com/shows/In+the+Office/Creating-WSS-30-Workflows-with-Visual-Studio-2005/

Customizing the Top Site Navigation in Sharepoint 2007

For customizing the top navigation bar in the SharePoint 2007, use the following links.



http://office.microsoft.com/en-us/sharepointtechnology/HA101191001033.aspx


http://www.devexpert.net/blog/pt/blog/Customizing-MOSS-2007-Navigation-Menu.aspx




http://faraz-khan.blogspot.com/2008/11/writing-custom-navigation-provider-for.html


http://www.codeproject.com/KB/sharepoint/spnav.aspx

Friday, May 21, 2010

value does not fall within the expected range in sharepoint Error

Wnen I was working on the authentication part of in my project using forms authentication, I got the error value does not fall within the expected range. I deleted the old page and created a new one and added the webparts to the page. The error got resolved.

Thursday, May 13, 2010

How to Add a Site Template by using stsadm in MOSS 2007

stsadm -o addtemplate -filename “D:\SiteTemplate.stp” -title “Project site template” -description “Project site template with a simple structure”

After adding the site template, the IIS must be reset. The template will be found in Custom site template collection.

Ref: http://blog.gavin-adams.com/2007/07/03/creating-site-collection-templates/

Wednesday, May 12, 2010

How to Save the Site Template in MOSS Site

Suppose you want to save the site template of your existing site in sharepoint, please follow the steps below.

If your site address is like

http://localhost:100/Paintings/Pages/Home.aspx

and you want to save the template of the painting site, then change the URL as

http://localhost:100/Paintings/_layouts/savetmpl.aspx

and press Enter button.

You will be getting a page Save Site as Template and enter the details and select the Include Content checkbox to save your site content and click OK button. The following fogure will be displayed.


After clicking Ok the success page will be displayed as below.

You can go to the site template gallery by clicking on the link Site Template gallery and click Ok to finish the opration.



Tuesday, May 11, 2010

Run time filtering of the records Using Select Expression in DataSet Or in DataTable.


This code is used to write the filter expression in the Dataset runtime.

 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
 {
      string expression = "Id = " + ds.Tables[0].Rows[i][0];
      DataRow[] rows = ds.Tables[1].Select(expression);
      foreach (DataRow row in rows)
      {
        DataRow newRow =                                                  myDescripterValueTable.Tables[i].NewRow();
                        newRow["Id"] = row["Id"];
                        newRow["value"] = row["value"];
                        myDescripterValueTable.Tables[i].Rows.Add(newRow);
      }
 }

How to select unique fields in DataSet or DataTable at runtime in C# & Ado.Net

Please refer the following code to filter the unique values from DataSet or DataTable at runtime.


DataTable dt=new DataTable();
DataTable dt = GetProductDetaila(); // Get all the details of product


DataView view = dt.DefaultView; // Create a dataview on the datatable


view.Sort = "ProductId,ProductName"; // Need to sort the records based on the ProductId and ProductName


DataTable newTable = view.ToTable("UniqueProductNames", true, "ProductId", "ProductName", 
"ImageURL"); 


// These are the unique entries in the dataset that are to be filtered. If you need more fields then write them in comma seperated values.

Friday, May 7, 2010

Walkthrough: Creating a Basic SharePoint Web Part

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

Deploying ASP.NET Web Applications in the Windows SharePoint Services 3.0 _layouts Folder

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

Manage SharePoint Farm Administration settings.

http://technet.microsoft.com/en-us/library/cc298750.aspx

http://technet.microsoft.com/en-us/library/cc298803.aspx#section1

Installing & Configuring Virtual Machine on Windows Server 2008 Hyper-V

http://www.windowsreference.com/hyper-v/hyper-v-how-to-create-a-new-virtual-machine/

http://techrepublic.com.com/2346-13628_11-242641-2.html?tag=content;leftCol

Installing & Configuring ForeFront Threat Management System.

http://www.isaserver.org/tutorials/Installing-Forefront-Threat-Management-Gateway-Forefront-TMG-Beta1.html

Installing and Configuring Team Foundation Server

http://support.microsoft.com/kb/969985

http://daveclarkesblog.blogspot.com/2008/07/installing-team-foundation-server-2008.html

http://geekswithblogs.net/michaelazocar/archive/2008/06/18/tfs-on-windows-2008-64-bit-step-by-step.aspx

Installation & Configuration of AD(Active Directory)

http://www.petri.co.il/installing-active-directory-windows-server-2008.htm

http://technet.microsoft.com/en-us/library/cc755258%28WS.10%29.aspx

http://technet.microsoft.com/en-us/library/cc754463%28WS.10%29.aspx

http://technet.microsoft.com/en-us/library/cc754438%28WS.10%29.aspx

http://technet.microsoft.com/en-us/library/cc755059%28WS.10%29.aspx

Sharepoint Installation and Configuration

Sharepoint Installation and Configuration

http://datanotes.wordpress.com/2007/11/15/part-1-sharepoint-30-installation-and-configuration-for-small-business-server/

http://blogs.msdn.com/harsh/archive/2006/06/07/620989.aspx

http://www.google.co.in/url?sa=t&source=web&ct=res&cd=13&ved=0CA8QFjACOAo&url=http%3A%2F%2Fwww.psspug.org%2FSharePoint%2520Conference%25202008%2FHands%2520On%2520Labs%2FMicrosoft%2520Office%2520SharePoint%2520Server%25202007%2520Installation%2520and%2520Configuration%2520-%2520HOL213.doc&rct=j&q=sharepoint+Installation+%26+Configuration&ei=LHbRS7XIOI27rAekh738DQ&usg=AFQjCNFNkJ2FpEDDH-P0zgwxT_G2MRuI-Q&sig2=CTGdH6rx9K0i6MH3BQuXLg

http://technet.microsoft.com/en-us/library/cc303422.aspx

Import & Export Sharepoint Site Collection

http://dhunter-thinkingoutaloud.blogspot.com/2007/07/stsadm-import-export.html

http://alancoulter.blogspot.com/2007/02/moss-2007-importexport-lessons-learnt.html

http://technet.microsoft.com/en-us/library/cc262465.aspx

http://technet.microsoft.com/en-us/library/cc262759.aspx

Backup & Restore Sharepoint Site

http://office.microsoft.com/en-us/sharepointdesigner/ha100699391033.aspx

http://www.dotnetspider.com/forum/200065-how-take-backup-sharepoint-site.aspx

http://blah.winsmarts.com/2006-12-Backup-Restore_a_site_collection_in_SharePoint_2007.aspx

Diffrence between WSS 3.0 & MOSS

Diffrence between WSS 3.0 & MOSS

http://dotnetaddict.dotnetdevelopersjournal.com/moss_vs_wss.htm

http://www.eb.net.nz/blog/post/2008/07/13/Differences-between-SharePoint-Services-and-Office-SharePoint-Server-Presentation-Explained.aspx

http://stackoverflow.com/questions/181920/windows-sharepoint-services-vs-microsoft-office-sharepoint-server

Configuring Shared Service Provider

For Configuring Shared Service Provider please refer the following links.

http://technet.microsoft.com/en-us/library/cc288969.aspx

http://technet.microsoft.com/en-us/library/cc263094.aspx

Creating or Extending Web Application

For Creating or Extending Web Application please refer the following links.

http://technet.microsoft.com/en-us/library/cc287954.aspx

http://technet.microsoft.com/en-us/library/cc262668.aspx

Step By Step Installtion of Sharepoint Server 2007

Please refer the following links for Step By Step Installation of Sharepoint server 2007.