Wednesday, 24 July 2013

Share Point Migration (SP 2010 to SP 2013)

Share Point migration 2010 to 2013

I need help for migration in SP. The followings are the high level key components those need to migrate from SP 2010. Any suggestions and approaches for the are appreciable.

1) I have one portal that need to be migrate from SP 2010 to SP 2013: 

    I) How to migrate portal from SP 2010 to 2013 from scratch without using any tools? 

   II) How to deploy visual  web parts to SP 2013. Is their any impact of app model? is it any changes are required to current visual web part like configuration changes etc?

2) In portal we are using SSRS reports and PPS:

    I) How to migrate SSRS reports from SP 2010 to SP 2013?
 
   II) Is all reports will come automatically when we restore content DB to SP 2013?

   III) If no then how to deploy from BID or is there any other options to optimize this work?

3) Also we have one external DB that needs to be migrated from SQL Server 2008 to 2012.

   I) What is the best approach to migrate database from SQL Server 2008 to SQL 2012?


Thanks in advance...  :) 

Thursday, 5 May 2011

AutoComplete Extender Example

 <asp:TextBox ID="txtPatName" runat="server" AutoPostBack="True" CssClass="textSearch"
                                    OnTextChanged="txtPatName_TextChanged" Width="300px"></asp:TextBox>
                                <div id="divwidth">
                                </div>
                                <cc1:AutoCompleteExtender ID="txtPatName_AutoCompleteExtender" runat="server" Enabled="True"
                                    MinimumPrefixLength="1" ServiceMethod="GetEmrPatientList" ServicePath="~/Service/EMRWebService.asmx"
                                    TargetControlID="txtPatName" CompletionSetCount="20" CompletionListItemCssClass="AutoExtenderList"
                                    CompletionListCssClass="AutoExtender" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                    CompletionListElementID="divwidth" DelimiterCharacters="">
                                </cc1:AutoCompleteExtender>

//Web Service As
private List<String> List(string key)
    {

        List<String> List = new List<string>();
        DataTable dtEmrPat = new DataTable();
        using (cls obj = new cls())
        {
            if (Session["XYZ"].ToString().Equals(""))
            {
                dt = obj.GetList(key);
            }
            else
            {
                dt = obj.GetAllLists(key);
            }

            if (dt != null && dt.Rows != null && dt.Rows.Count > 0)
            {
                Session["EmrPatients"] = dt;
                foreach (DataRow dr in dt.Rows)
                {
                    stringname = dr["Name"].ToString();
                    List .Add(stringname );
                }
            }
            return List ;
        }
    }

Tuesday, 3 May 2011

Load Page In IFrame Through JQuery

<script language="javascript" type="text/javascript">
$(document).ready(function(){
 
   $('#A').click(function(){
      ShowPage('A');
   });
  
   $('#A1').click(function(){
      ShowPage('A1');
   });
  
   $('#A2').click(function(){
      ShowPage('A2');   
   });
  
    function ShowPage(PageName)
    {
       if(PageName=='A')
       {
           $('#frame').attr('src','A.aspx');   
           $('#frame').css('height',600);
           $('#lblPageName').text('A');
       }
       else if(PageName=='A1')
       {
           $('#frame').attr('src','A1.aspx');   
           $('#frameEMR').css('height',200);
           $('#lblPageName').text('A1');
       }
       else if(PageName =='A2')
       {
           $('#frame').attr('src','A2.aspx');   
           $('#frame').css('height',100);
           $('#lblPageName').text('A2');
       }
    }
});
</script>

Tuesday, 26 April 2011

Grid with data key

<asp:GridView ID="gv" runat="server" Width="70%"   AutoGenerateColumns="false"
                    OnSelectedIndexChanged="gv_SelectedIndexChanged" DataKeyNames="Id">
                    <Columns>
                        <asp:CommandField ShowSelectButton="true" ItemStyle-Width="10pt" />
                        <asp:BoundField DataField="Name" HeaderText="Name" />
                    </Columns>
                </asp:GridView>

Call Explicitly Javascript function After Some Server Side Code

Page.ClientScript.RegisterStartupScript(GetType(), "delMsg", "alert('Record Deleted');", true);

ScriptManager.RegisterClientScriptBlock(upSSP, upSSP.GetType(), "BindSWF", "CreateSSPSwf();", true);

Saturday, 23 April 2011

Grid View Selected key

<asp:GridView ID="gvExamInGr" runat="server" AutoGenerateColumns="False" EmptyDataText="Record Does Not Exist"
                            DataKeyNames="GrNo" OnSelectedIndexChanged="gvExamInGr_SelectedIndexChanged">


GrNo = Convert.ToInt64(gvExamInGr.SelectedDataKey.Value.ToString());

Tuesday, 19 April 2011

Toggle the Div in JavaScript

function ToggleContent(dvToggle)
{  
    var contentId = document.getElementById(dvToggle);
    contentId.style.display == "block" ? contentId.style.display = "none" :
    contentId.style.display = "block";
}

Monday, 18 April 2011

Page Load Settings

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Request.QueryString["GroupId"] != null && Request.QueryString["GroupId"].ToString() != "")
            {
                requestGroupId = Request.QueryString["GroupId"].ToString();
                lblMode.Text = "Edit";
                btnSave.Text = "Update";
            }

            if (!IsPostBack)
            {
                this.BindRecord();
            }

            txtGroup.Focus();

        }
        catch (Exception ex)
        {
            lblMessage.Text = ex.Message;
            lblMessage.CssClass = clsGlobal.css.SmallError;
            clsExceptionManager.Publish(ex);
        }

    }

Bind Value As

<asp:TemplateField HeaderText="Edit"><ItemTemplate>
<asp:HyperLink id="hypGroup" runat="server" ImageUrl="~/Images/Edit.png" ToolTip="Edit" NavigateUrl='<%# Eval("ProductGroupId","ProductGroup.aspx?GroupId={0}") %>' __designer:wfdid="w32"></asp:HyperLink>
</ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete"><ItemTemplate>
<asp:ImageButton id="imgBtnDeleteGroup" onclick="imgBtnDeleteGroup_Click" runat="server" OnClientClick="javascript:return confirm('Continue with delete?');" ImageUrl="~/Images/Delete.png" ToolTip="Delete" __designer:wfdid="w31" CommandArgument='<%# Eval("ProductGroupId") %>'></asp:ImageButton>
</ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>

Wednesday, 13 April 2011

Check When Repeater control data bound

protected void reptrMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            //Code
        }
    }

Sunday, 10 April 2011

Add items from One list box to other list box through JQUERY

1) Add items from One list box to other list box through JQUERY
$(document).ready(function() {

            $("#btnAddToList").click(function() {
                $(".lstProduct > option:selected").appendTo(".lstSelectedProduct");
            });
        
            $("#btnRemoveFromList").click(function() {
                $(".lstSelectedProduct > option:selected").appendTo(".lstProduct");
            });
 });   

Cursors to operate row by row in table

DECLARE    @StateId INT,
        @StateName NVARCHAR(100),
        @StateCode NVARCHAR(5)
       
DECLARE Cur_State CURSOR
LOCAL SCROLL STATIC
FOR SELECT SM.StateId,SM.StateName FROM StateMaster SM

OPEN Cur_State
    FETCH NEXT FROM Cur_State INTO  @StateId,@StateName
    WHILE @@FETCH_STATUS=0
    BEGIN   
           
            SET @StateCode = SUBSTRING(@StateName,(CHARINDEX('(',@StateName,0)+1),3)
            SET @StateName = SUBSTRING(@StateName,0,CHARINDEX('(',@StateName,0))
                   
           
            UPDATE StateMaster SET StateName=@StateName,StateCode=@StateCode WHERE StateId=@StateId
           
                --PRINT @StateName+ ' '+ @StateCode
                   
                   
   
        FETCH NEXT FROM Cur_State INTO  @StateId,@StateName
    END
    CLOSE Cur_State
    DEALLOCATE Cur_State

Friday, 8 April 2011

Include Javascripts from JS File to Aspx Page

1) Add Javascript file

function manageFocus(e,objFocusOn)
{
    try
    {
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
        {
            if(objFocusOn != null)
            {
                objFocusOn.focus();
                objFocusOn.select();
            }
             return false;
        }
        else
        {
            return true;
        }
   
    }catch(error)
    {
        var showerror="There was an error on this page.\n\n";
        showerror+="Error : " + error.description + "\n\n";
        showerror+="Error description: " + error + "\n\n";
        showerror+="Click OK to continue.\n\n";
        alert(showerror);
    }
}

2) Add reference of JS file in APSX page as
<script type="text/javascript" src="Scripts/Sales.js" language="javascript"></script>

3) Call the functions of JS file we can call in ASPX page or add the attributes of controls in .cs file of page
 txtRate.Attributes.Add("onkeyup", "javascript:manageFocus(event," + txtEnteredQty.ClientID + ");");

Wednesday, 6 April 2011

Take the values from gridview

//Take the values from GridView 
String strSelected_AnnouncementID = ((ImageButton)sender).CommandArgument;

Boolean Stutus = (Boolean)DataBinder.Eval(e.Row.DataItem, "Status");

//Get control of GridView

ImageButton imgStatus = (ImageButton)e.Row.FindControl("imgStatus");

Read XML File in SQL Server

--1)--BUILD TABLE FROM XMLDOCUMENT----------------------------------
declare @DocHandle As INT
    DECLARE @t as table
    (   
             EmpID VARCHAR(100),
             Name VARCHAR(100),           
             City VARCHAR(100),               
             Title VARCHAR(100)
        ) 
       
    EXEC SP_XML_PREPAREDOCUMENT @DocHandle OUTPUT,'<DocumentElement>
  <P>
    <EmpID>1</EmpID>
    <Name>Prashant</Name>
    <City>Hupari</City>
    <Title>Sales</Title>
  </P>
  <P>
    <EmpID>2</EmpID>
    <Name>Suhas</Name>
    <City>Hupari</City>
    <Title>Marketing</Title>
  </P>
   <P>
    <EmpID>3</EmpID>
    <Name>Mahesh</Name>
    <City>Kolhapur</City>
    <Title>Purchase</Title>
  </P>
  <P>
    <EmpID>4</EmpID>
    <Name>Rajesh</Name>
    <City>Pune</City>
    <Title>Marketing</Title>
  </P>
  
 </DocumentElement>'    

    INSERT INTO @t SELECT * FROM OPENXML (@DocHandle, '/DocumentElement/P',2) 
    WITH (   
             EmpID VARCHAR(100),
             Name VARCHAR(100),           
             City VARCHAR(100),               
             Title VARCHAR(100)
        )   
          
    EXEC SP_XML_REMOVEDOCUMENT @DocHandle 
    select * from @t
   
 --OR--
2)
USE [odLibrary]
GO
/****** Object:  StoredProcedure [dbo].[sp_lib_Check_Student_and_Add_In_Library]    Script Date: 10/31/2010 11:53:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[sp_lib_Check_Student_and_Add_In_Library]   
(   
    @TransactionStatus BIGINT OUTPUT,
    @strXML NVARCHAR(MAX)
)   
AS   
BEGIN       
    BEGIN TRANSACTION 
   
    --Declare local variables-------------------------------------
    DECLARE @USERNAME AS VARCHAR(100)
    DECLARE @USERCODE AS VARCHAR(100) 
    DECLARE @PPASSWORD AS VARCHAR(100)   
    DECLARE @SSTATUS AS BIT
    DECLARE @CREATED_BY AS BIGINT
    DECLARE @UPDATED_BY AS BIGINT     
    DECLARE @COMPANY_ID AS BIGINT
   
    DECLARE @FULL_NAME AS NVARCHAR(500)
    DECLARE @FIRST_NAME AS NVARCHAR(500)
    DECLARE @MIDDLE_NAME AS NVARCHAR(500)   
    DECLARE @LAST_NAME AS NVARCHAR(500) 
    DECLARE @BATCH AS VARCHAR(50) 
   
    DECLARE @DocHandle AS INT 
   
    DECLARE @tblStudent TABLE
    (                   
        USERNAME VARCHAR(100),
        USERCODE VARCHAR(100),           
        PPASSWORD VARCHAR(100),               
        SSTATUS BIT,               
        CREATED_BY BIGINT,
        UPDATED_BY BIGINT,
        COMPANY_ID BIGINT       
    ) 
   
    DECLARE @tblStudentFinal TABLE
    (       
        [CompanyId] BIGINT,
        [LibDepositAmount] DECIMAL(18, 2),
        [FirstName] VARCHAR(500),
        [LastName] VARCHAR(500),
        [Address] VARCHAR(1000),
        [State] VARCHAR(500),
        [City] VARCHAR(500),
        [Email] VARCHAR(500),
        [Notes] NTEXT,
        [Batch] VARCHAR(50),
        [CreatedBy] BIGINT,
        [CreatedOn] DATETIME,
        [UpdatedBy] BIGINT,
        [UpdatedOn] DATETIME,
        [Username] VARCHAR(100),
        [Password] VARCHAR(100),
        [Status] BIT,
        [RoleId] INT,
        [MiddleName] VARCHAR(500),
        [Student_Code] VARCHAR(500)
    )
    -------------------------------------------------------------- 
 
    ----BUILD TABLE FROM XMLDOCUMENT----------------------------------
    EXEC SP_XML_PREPAREDOCUMENT @DocHandle OUTPUT, @strXML      

    INSERT INTO @tblStudent SELECT * FROM OPENXML (@DocHandle, '/STUDENTS/ROW',2) 
    WITH (   
             USERNAME VARCHAR(100),
             USERCODE VARCHAR(100),           
             PPASSWORD VARCHAR(100),               
             SSTATUS BIT,               
             CREATED_BY BIGINT,
             UPDATED_BY BIGINT,
             COMPANY_ID BIGINT       
        )   
          
    EXEC SP_XML_REMOVEDOCUMENT @DocHandle  
    -------------------------------------------------------------- 

    --CREATE CURSOR--------------------------------------------- 
    DECLARE  cur_students CURSOR 
    LOCAL SCROLL STATIC 
    FOR SELECT USERNAME, USERCODE, PPASSWORD, SSTATUS, CREATED_BY, UPDATED_BY, COMPANY_ID FROM @tblStudent 
      
    --OPEN CURSOR 
    OPEN cur_students           
        FETCH NEXT FROM cur_students INTO @USERNAME, @USERCODE, @PPASSWORD, @SSTATUS, @CREATED_BY, @UPDATED_BY, @COMPANY_ID
        WHILE @@FETCH_STATUS=0 
        BEGIN   
            --find users (firstname, middlename, lastname, batch)-------------
            --SELECT DISTINCT([User_ID]),@BATCH=BATCH_CODE,@FULL_NAME=B.STUDENT_NAME FROM Users A
            --INNER JOIN TRNMARKS B ON A.[USER_ID]=B.UNIQUE_ID
            --WHERE [USER_ID]=@USERNAME
           
            --split value------------------------------------------------------
            --GET FIRST NAME
            SELECT  @FIRST_NAME = item FROM [dbo].fnSplit(@FULL_NAME,' ')

            --GET MIDDLE NAME
            SET @FULL_NAME =  REPLACE(@FULL_NAME,@FIRST_NAME,'')
            SELECT  @MIDDLE_NAME  = item FROM [dbo].fnSplit(@FULL_NAME,' ')

            --GET THIRD NAME
            SET @FULL_NAME =  REPLACE(@FULL_NAME,@MIDDLE_NAME,'')
            SELECT  @LAST_NAME  = item FROM [dbo].fnSplit(@FULL_NAME,' ')
           
            --- First Check this student is already exist or not   
            DECLARE @retStudentId BIGINT       
            SET @retStudentId=0       
            SELECT @retStudentId = ISNULL(StudentId,0) FROM lib_studentmaster WHERE [StudentCode] = LTRIM(RTRIM(@USERCODE))            
            IF @retStudentId = 0   
            BEGIN         
                --INSERT VALUES--------------------------------------------------
                INSERT INTO [lib_studentmaster]   
                (
                    [CompanyId]   
                   ,[LibDepositAmount]   
                   ,[FirstName]   
                   ,[LastName]   
                   ,[Address]   
                   ,[State]   
                   ,[City]   
                   ,[Email]   
                   ,[Notes]   
                   ,[Batch]   
                   ,[CreatedBy]   
                   ,[CreatedOn]   
                   ,[UpdatedBy]   
                   ,[UpdatedOn]   
                   ,[Username]   
                   ,[Password]   
                   ,[Status]   
                   ,[RoleId]
                   ,[MiddleName]
                   ,[StudentCode]
                ) 
                VALUES   
                (   
                    @COMPANY_ID   
                   ,'0.0'   
                   ,@FIRST_NAME   
                   ,@LAST_NAME   
                   ,'Address'   
                   ,'Maharashatra'   
                   ,'Kolhapur'   
                   ,'vijeta@rediffmail.com'   
                   ,'Notes'   
                   ,@BATCH   
                   ,@CREATED_BY   
                   ,GETDATE()   
                   ,@UPDATED_BY   
                   ,GETDATE()   
                   ,@USERNAME   
                   ,@PPASSWORD   
                   ,@SSTATUS   
                   ,2
                   ,@MIDDLE_NAME
                   ,@USERCODE
                ) 
            END   
            ELSE   
            BEGIN 
                UPDATE lib_studentmaster SET [Status]=@SSTATUS, [FirstName]=@FIRST_NAME, [LastName]=@LAST_NAME , [MiddleName]=@MIDDLE_NAME               
                WHERE StudentId = @retStudentId                    
               
                UPDATE Users SET IsAllowLibrary=@SSTATUS WHERE [Student_Code] = LTRIM(RTRIM(@USERCODE))                        
            END                         
            --------------------------------------------------------------
        FETCH NEXT FROM cur_students INTO @USERNAME, @USERCODE, @PPASSWORD, @SSTATUS, @CREATED_BY, @UPDATED_BY, @COMPANY_ID
        END 
    --DEALLOCATE AND CLOSE CURSOR 
    CLOSE cur_students 
    DEALLOCATE cur_students  
  -----------------------------------------------------------------        
       
    IF @@ERROR > 0   
    BEGIN   
        ROLLBACK TRANSACTION    
        RETURN @TransactionStatus   
    END   
    ELSE   
    BEGIN   
        COMMIT TRANSACTION  
        SET @TransactionStatus = 1
        RETURN @TransactionStatus   
    END       
END



Get which radio button is selected

 function Check()
    {
    alert('a');
    var radios=document['form1'].elements['n'];
    for(var i=0;i<radios.length;i++)
    {
    
     if(radios[i].checked==true)
     {
      alert('Checked');
     alert(radios[i].value);
     }
   
    }
    }

Select Count of GridView CheckBox column


 function SetSelectedCount()
    {
       try
        {
            var TotalUsers=0;
            var SelectUsers=0;
           
                var grid = document.getElementById("<%= grdClients.ClientID%>");
                var cell;           
                if (grid.rows.length > 0)
                {
                    for (i=1; i<grid.rows.length; i++)
                    {
                        cell = grid.rows[i].cells[0];                   
                        for (j=0; j<cell.childNodes.length; j++)
                        {          
                            if (cell.childNodes[j].type =="checkbox")
                            {
                                TotalUsers +=1;
                                if(cell.childNodes[j].checked)
                                {
                                    SelectUsers+=1;
                                }
                            }
                        }           
                    }
                }
               

            var msg= SelectUsers + ' of '+ TotalUsers +' Selected ';
            document.getElementById('<%= lblSelectUserCount.ClientID %>').innerHTML=msg;
        }
        catch(error)
        {
            alert(error);
        }
              
    }
   

Generic Handler

//Handler Class
1)Include js file

2) Add HTTP Handler
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;

public class Handler : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        if (context.Request.QueryString["str"] != null)
        {
            string str = context.Request.QueryString["str"].ToString();
            context.Response.Write('1');
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}

3) In code behind file
<script type="text/javascript" language="javascript" src="jquery-1.4.2.min.js"></script>
    <script language="javascript" type="text/javascript">
        function callhandler()
        {
      
            var str='Called';
            var param='str='+escape(str);
            $.ajax({
                   type:'GET',
                   url:'Handler.ashx',
                   data:param,
                   success:function(returnResponse)
                   {
                   
                         alert(returnResponse);
               
                  
                   }
           
            });
       
       
        }

    </script>

4) in Code behind file i.e. when you want to call the function write
protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Attributes.Add("onclick", "javascript:callhandler()");
    }





Thursday, 6 January 2011