Tuesday, July 21, 2015

Get multiple dropdown value using JQuery

Here is how my HTML looks
 Here is the HTML and JS

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-2.1.4.min.js"></script>

    <script type="text/javascript">

        $(document).ready(function () {
            $("#selectedCountries").change(function () {
                var selectedOption = $("#selectedCountries option:selected");
                if (selectedOption.length > 0) {
                    var resultString = '';

                    selectedOption.each(function () {
                        resultString += "Value =" + $(this).val() + ", Text=" + $(this).text() + "<br/>";

                    });

                    $(divResults).html(resultString);

                }


            });
        });
    </script>
</head>

<body>
    Country :
    <select id="selectedCountries" multiple="multiple">
        <option value="USA">United States</option>
        <option value="India">India</option>
        <option value="UK">United Kingdom</option>
        <option value="CA">Canada</option>
        <option value="AU">Australia</option>
    </select>

    <br />
    <br />

    <div id="divResults">
    </div>

</body>

</html>


Results : You can select control and options in dropdown, it will show values for selected dropdown items




See Demo here : https://jsfiddle.net/2dmg861f/1/

Getting dropdown value using JQuery

This is how my HTML looks 

Here is the HTML and JS

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-2.1.4.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#selectedCountries").change(function () {

                var selectedOption = $("#selectedCountries option:selected");

                $(divResults).html('Value = ' + selectedOption.val() + ",Text = " + selectedOption.text());

            });

        });

    </script>

</head>

<body>

    Country : 

<select id="selectedCountries">
<option value="USA">United States</option>
<option value="India">India</option>
<option value="UK">United Kingdom</option>
<option value="CA">Canada</option>
<option value="AU">Australia</option>


</select>

<br/><br/>

<div id="divResults"> 


</div>

</body>

</html>


Results : If dropdown is selected, it will show its value and text as follows 








Wednesday, July 15, 2015

Getting checkbox value using JQuery

                               This is how my HTML looks 


Here is the HTML and JS

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-2.1.4.js"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $('#btnSubmit').click(function () {
           
                 var result = $('input[type="checkbox"]:checked') // this return collection of items checked
                 if (result.length > 0) {
                     var resultString = result.length + " checkboxe(s) checked <br/><br/>"

                     result.each(function () {
                         resultString+= $(this).val() + "<br/>";
                     });

                     $('#divResult').html(resultString);

                 }
                 else {
                     $('#divResult').html(" No checkbox  is checked");
                 }

             });
         });
         

</script>
   
</head>
<body>
   Skills :
    <input type="checkbox" name="skills" value="JavaScript" /> JavaScript
    <input type="checkbox" name="skills" value="JQuery" /> JQuery
    <input type="checkbox" name="skills" value="C#" /> C#
    <input type="checkbox" name="skills" value="VB" /> VB
        <br />
    <br />
<input id="btnSubmit" type="submit" value="submit" />
    <br />
    <br />
    <div id="divResult">

    </div>
</body>
   

</html>


Results : 

It gets values of checkboxes that are selected on Submit button click event



If no checboxes are selected and Submit button is clicked appropriate message is displayed.




Getting radio button value using JQuery

This is how my HTML looks and I am going to show to get value of  the radio button that is selected :



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-2.1.4.js"></script>
     <script type="text/javascript">
         $(document).ready(function () {
           
        $('#btnSubmit').click(function () {

                 var result = $('input[type="radio"]:checked')

                 if (result.length > 0) {
                     $('#divResult').html(result.val() + " is checked");
                 }

                 else {
                     $('#divResult').html(" Nothing is checked");
                 }

             });
         });
       

</script>
 
</head>
<body>
   Gender :
    <input type="radio" name="gender" value="Male" />Male
    <input type="radio" name="gender" value="Female" />Female
        <br />
    <br />
<input id="btnSubmit" type="submit" value="submit" />
    <br />
    <br />
    <div id="divResult">

    </div>
</body>
 

</html>



Results : 


If nothing is selected and if clicked on Submit button ,  it displays message : "Nothing is checked"




If any radio button is selected and if clicked on Submit button, it displays value of respective checkbox






Tuesday, June 2, 2015

Incompactible error in Visual Studio 2012 for SharePoint 2013 projects

I came across this error after installing VS 2012 and when I was trying to open SharePoint 2013 projects.

All my projects were not loading and showed incompatible error

This article proposes solution to one of many reasons for this error 

Solution :

VS 2012 when installed does not install project templates for SharePoint 2013.

So if to go to File- > New->Project->Office Apps-> you can only see SharePoint 2010 templates

so now you need to install templates for SharePoint 2013, by default SharePoint 2013 templates do not get installed and they have to be installed seperately

You can find file to download on this url :

Download each project on by one and install all mentioned in the link

http://blogs.msdn.com/b/timquin/archive/2013/01/22/setting-up-visual-studio-2012-for-sharepoint-2013-development-offline.aspx

Once you install this, all your projects would open,work and get deployed as required
Cheers !

I had to write this blog because none of the available blogs have addressed this simple solution and because I wasted my 2 working days trying to figure out the issue

Even if this does not work :

  • Donwload and install SDK patch
  • Download and install KB2781514 for Visual Studio
Hope this helps 





Tuesday, May 26, 2015

Passing data from one page to another in Angular js

This articles shows the same,how this can be done


I want to pass the string value on a click event

Passing from  test.html  to testing.html

Step 1 : Sending string

test.html

passing on ng-click event

<li class="col-sm-6 col-md-6 col-lg-6 "><a ng-click="passResults()"><i class="fa fa-arrow-circle-o-right"></i> Pass </a></li>


test.js

passResults method which uses location.href and the text that I want to pass,here I am passing text from a text box, ng-model of text box is searchText

$scope.passResults = function () {

                              location.href = siteURL + $scope.searchText;

                          }


Step 2 : Collecting string

testing.html

Nothing needs to be done in HTML

Testing.js

$scope.searchItem = location.hash.split("/")[3];//split index may vary, you will understand why I did this if you take a look at my $routeProvide

This gets me text which was search in the textbox

Step 3 : Make changes to Admin App

For passing string from one page to another page primaryNav is the keyword, NO OTHER WORD can be used


AdminApp.js


app.config(function ($routeProvider) {
        $routeProvider
            .when('/MyProject/SeeAll/:primaryNav', {
                templateUrl: '../../Style Library/Scripts/ABC/ABC/Admin/Templates/testing.html',
                controller: 'MyCtrl'
            })




Hope this helps !




Friday, May 15, 2015

Create a new Service Application button is greyed out/disbaled in Central Admin - SharePoint 2013

Hi All,

I was trying to configure search in my SharePoint 2013 site so I created new farm account and when I was trying to create a new Search Service Application, the New Service application was greyed out/disabled in Central Admin

Solution : Restart the server and the button would be enabled

This at least worked in my scenario.

Hope this helps :)

If this article has helped you,don't forget to leave me a comment as this would encourage me to write more articles.  

Thanks
Jiniv Thakkar
MCP
Pune,India

Applying Custom CSS to MasterPage in SharePoint 2013/Add Custom Stylesheets to SharePoint 2013

Hi All,

This article describes one of the ways to apply your custom CSS to your Master Page without touch/editing your MasterPage in SharePoint Designer 

Step 1 :  Go to Site Settings-> Site collection Features->SharePoint Server Publishing Infrastructure ->Activate 

Step 2 : Site Settings-> Manage Site Features->SharePoint Server Publishing->Activate  

Step 3 :  Now navigate to Site Settings->Master Page -> Alternate CSS URL->Specify CSS file to be used >Browse and select the CSS that you have uploaded in Style library 

TaDa CSS will be changed :) 

If this article has helped you,don't forget to leave me a comment as this would encourage me to write more articles.  

Thanks 
Jiniv Thakkar 
MCP 
Pune,India


Monday, February 2, 2015

Database migration from SQL 2008 to SQL 2012 for SharePoint 2010

Hi All,

We recently updated the database for our SharePoint 2010 application as Microsoft has stopped support for SQL 2008
Steps migratiing database are as follows :


  1. Install SharePoint SP1(Service Pack 1) on Application server and reboot. Test the application and make sure it is working fine 
  2. Install SharePoint SP1(Service Pack 1) on WFE server and reboot. Test the application and make sure it is working fine.
    Note : Service Pack installation is mandatory 
  3. Once your application is working fine, you need to stop following services on application server and WFE 
  4. *SharePoint 2010 Administration
  5. *SharePoint 2010 Timer
  6. *SharePoint 2010 Tracing
  7. *SharePoint 2010 User Code Host
  8. *SharePoint 2010 VSS Writer
  9. *SharePoint Foundation Search V4
  10. *SharePoint Server Search 14
  11. *World Wide Web Publishing Service
  12. *SharePoint Server Search 14
  13. *SharePoint Foundation Search V4
  14. *SharePoint Server Search 14
  15. *Web Analytics Service(in services.msc)
  16. * IIS
  17. Ensure no connection exists on the databases (Run command sp_who2 on SQL instance "Servername\Instance name" and confirm.Kill the connections if needed.
  18. Backup content database & custom database
    Note : Make sure there is enough space to take back up and other drives.
  19. Detach all user databases using and secure respective .mdf & .ldf files.Ensure all the user databases are detached before proceeding further.
  20. Start uninstall process of SQL 2008 R2. Select your database instance while uninstalling.
  21. Once uninstallation completed, re-boot the machine
  22. Start installing SQL 2012
  23. Ensure data drives and backup drives are configured to drives which have ample of space to cope up with database size requirements.
  24. Ensure Instance name 
  25. Make sure to add your Admin users and sa account as Administrators
  26. Attach all the database which were detached in earlier steps 
  27. Change database property to SQL 2012
    Will update any details/scripts related to this shortly
  28. Start all the stopped services and start IIS
  29. Test you application 
Tada ! Its should work :) 
You can also user performance monitor tool to make sure the data hasn't changed before and after database migration.
I am pretty much sure that this strategy can work on any version of SharePoint but I would advice you to carry this activities on Development server and upon successful execution can be carried on Production servers


Tuesday, October 28, 2014

Powershell training/basics

·         Always run Powershell as Administrator

·         Make sure Add-PSSnapin "Microsoft.SharePoint.Powershell" is added
If this reference is not added you will get not recognized as cmdlet,function…. Error






This can be resolved by adding Add-PSSnapin "Microsoft.SharePoint.Powershell"

    

·         Commenting,writing and in .ps1 files

Example : I have a Powershell.ps1

--Start of Script---

#Test.ps1 This is will add comment to Test powershell script

#Add
Add-PSSnapin "Microsoft.SharePoint.Powershell"

#This will write to output window
Write-Host This is Test powershell script

#Writing in different colours
Write-Host -f Red I am Red
Write-Host -f Yellow I am Red

#This will make sure the output does not disappear
powershell –noexit

--End of Script--


You can copy paste the script in txt file and save it as Powershell.ps1
On running this the output should look like this





Note : Many times the output window disappears and we fail to read the output, add the following command to retain the output window
powershell –noexit

·         Calling a function

The difference in .Net or other techniques of calling function is that in Powershell you first need to define the function and then you can make a call to function
Also it does not need circular bracket to call the function just the name of function(See example below)

--Start of Script---

#Test.ps1 This is will add comment to Test powershell script

#Add
Add-PSSnapin "Microsoft.SharePoint.Powershell"

function MySolution()
{
                Write-Host -f Yellow "I am in MySolution function"
                #Do something
}


#This is how you call a function
MySolution

#This will make sure the output does not disappear
powershell –noexit

--End of Script--

You can copy paste the script in txt file and save it as Powershell.ps1
On running this the output should look like this


  
·         Accepting inputs and doing something


--Start of Script---

#Test.ps1 This is will add comment to Test powershell script

param (
       
      [string]$action = "$(Read-Host ' Please specify the operation which you want to carry - [Add] [Retract] [Deploy] [Remove]')"
)

#Add
Add-PSSnapin "Microsoft.SharePoint.Powershell"

function AcceptInput()
{
if ($action -eq "Add")  {
               
Write-Host -f Yellow Do something if condition matches       

}
}


AcceptInput

#This will make sure the output does not disappear
powershell –noexit

--End of Script--

You can copy paste the script in txt file and save it as Powershell.ps1
On running this the output should look like this


   
Keep watching this space for more advanced scripts,would publish it soon


System.Security.Cryptography.CryptographicException was thrown. Additional exception information: The data is invalid.

Resolution :

Step 1:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14

On the 14 Properties dialog under the Security tab, select Edit.
Permissions for 14 dialog click Add… and enter the account you are using to install SharePoint example(yourdomain\username) and assign full control and Add-OK

Step 2:

Open regedit , Navigate to the following

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\FarmAdmin

Delete     CredentialKeyDPEnt key

Try installing SharePoint once again






Monday, October 27, 2014

System.Net.WebException: The remote server returned an error: (503) Server Unavailable.

This issue comes when there is some issue with SecurityTokenServiceApplication

Run the following command on Powershell and the issue will be resolved

Add-PSSnapin "Microsoft.SharePoint.Powershell"

$h = Get-SPServiceHostconfig

$h.Provision()

$services = Get-SPServiceApplication

foreach ($service in $services) { $service.provision();
write-host $service.name}


If you have any issues in executing this commands,copy paste the above powershell script lines and create a .ps1 file and execute the .ps1 file
Example :

STS.ps1

Add-PSSnapin "Microsoft.SharePoint.Powershell"

$h = Get-SPServiceHostconfig

$h.Provision()

$services = Get-SPServiceApplication

foreach ($service in $services) { $service.provision();
write-host $service.name}

powershell –noexit



Run powershell as admin – Location for your PS1 file and name of PS1 file

It will be something like this PS

 C:\Windows\system32> C:\Users\jiniv\\Desktop\STS.ps1


More Details and Reference from
                    

Wednesday, October 1, 2014

Powershell output disappears

Add powershell -noexit at the end of your code. 


Example :

your script
powershell-noexit  

Add this command at the end of the your script,this will display the output window as long as you don't close it manually :P


Reference :

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\M icrosoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.

Resolution for this :

* Run: regedt32
* Goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell
* Right-Click > Permissions
* Select, and add your account, grant it "Full Control" privileges

It helped me out, being "alternative" admin, on my machine, which was prepped by an operations 
admin

Reference : 


Thursday, July 24, 2014

Techsignia Solutions SharePoint Interview Questions

Once again gave this interview without any preparation.Opening was for SharePoint Software Engineer.


  1. Introduction - a brief one with all details of work
  2. Lets say you have 40 sites and their content databases in SharePoint 2010 with SQL 2008 as back-end and you want to upgrade to SQL 2012 with SharePoint 2010 only but when migrating to 2012,there should be only 1 content DB and this content DB should contain all the content DB for 40 sites? 
  3. What is difference between Farm and Sandbox solutions
  4. How do you debug Farm & Sandbox solutions ?
  5. Can MVC implemented in SharePoint 2013 as MVC is implemented in .Net Framework 4.5?
  6. Methods to retrive list data ? 
  7. What is difference between CAML & LINQ,which one is easy for system to understand ?
  8. Which would you prefer CAML or LINQ and why ?
  9. CAML returns ListItemCollection and LINQ returns IEnumerable ? what does this mean ? Elaborate this ? which is better ? 
  10. How can the highest permission be given ? The interviewer was referring to RunWithElevatePrevilages 
  11. What is the use of it and when it can be used,what happens when used?
  12. If you have a piece of code which is 
          SPuser something = SPContent.CurrentUser; 
          
          What value does above value return when used with REWP and when used without REWP

  13.   I want to create a Web Service for a list how will I do it ? Answer: SharePoint already provides OOB list web service which list.asmx
  14.   Which one is lighter and faster when comes to access data from list ? CAML,COM or LINQ


That it ! It was very easy..like fucking easy..I could have cracked in if I they asked me such questions when  I was kid..jk :P
This was Round 1: Telephonic 
which I cleared I was called for Round 2: Face 2 Face Interview,if I attend will update the questions else end of post.
TaDa :)

What is Managed Path in SharePoint ?

What is Managed Path ?

By default, every WebApp comes with a wildcard managed path called "sites".
Example: So I could create http://myserver:7676/sites/team1

Why to create Managed Path ?

To have a specific URL other than /site we would have to create a Managed Path.
When we create a Managed Path, we have two options:   Explicit Inclusion
                                                                                              Wildcard Inclusion

Explicit inclusion :

When we are not planning to create further site collections under a specified managed path, then we use this option.
Explicit Inclusion Managed paths allows in creation of only one site collection at the exact given URL.

Example : http://myserver:7676/IT

Wildcard Inclusion :

When we want to create more than one site collection under a specific managed path, we use this option. Wildcard Inclusion Managed Paths allow unlimited site collection to be created under a given URL.

Example: http://myserver:7676/TataGroup
                http://myserver:7676/TataGroup/TCS
                https://myserver:7676/TataGroup/BPO
                https://myserver:7676/TataGroup/TataMotors

Adding Managed Path

1) Go to Central Admin->Manage Web Application ->Select the desired Web Application -> Select Managed Path from Ribbon

2) In add a new Path textbox enter  ->      \IT
Select Explicit Inclusion – Click on Add Path

3) In add a new Path textbox enter ->        \tatagroup
Select Wildcard Inclusion – Click on Add Path

Image shows how to add a Explicit inclusion Managed Path

   How this works :

  Wildcard inclusion: What happens when I try to create a site collection
   

After the managed path term”tatagroup” we created,I add a name corresponding to my subsite.I can keep creating as many site collections I want.

E     Explicit inclusion 



When I try to create a site collection with the managed path ”it” there is no textbox which indicates that I can have only 1 site collection and no further site collections can be created a with the managed path”it”


Reference : 


Tuesday, July 15, 2014

SQL error log file location

1. Click Start -> Programs -> Microsoft SQL Server 2008/2012 -> Configuration Tools -> SQL Server Configuration Manager

2. In SQL Server Configuration Manager, click SQL Server Services on the left side and then right click on SQL Server (MSSQLSEVER) and select Properties from the drop down as shown below. For a named instance, right click on the appropriate SQL Server (INSTANCENAME) service.

3. In SQL Server (MSSQLSERVER) Properties window click on the Advanced tab and then expand the drop down next to Startup Parameters. The location of SQL Server Error Log file is mentioned next to the "-e" startup parameter

Navigate to the physical file location and open it or u can also use SQL query to get log details

EXEC sp_readerrorlog



Reference : 

http://www.mssqltips.com/sqlservertip/2506/identify-location-of-the-sql-server-error-log-file/


SQL Query to get SQL Error Logs

Go to SQL -> New Query and paste the following query it should return you the latest Error log

EXEC sp_readerrorlog


For more details and reference :