How to avoid page refresh,flickring in postback

It is very very simple to avoid p page refresh in post-back . To get this we just have to use ASP "Update Panel Control" it will not refresh the page again and again on post-back.


Here is an example.

In Default.aspx



<asp:UpdatePanel ID="pnlPageRefresh" runat="server">
        <ContentTemplate>
            <div>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                </asp:DropDownList>
                <br />
                <asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"></asp:TextBox>
                <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
                </asp:RadioButtonList>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
<div>
<asp:Button ID="btnSave" runat="server" Text="Button" />
</div>


After using this your page will not at all refresh again and again on post-back. Your code will work fine but refresh flickering will not occur.

BlogEngine.NET Application Error when uploading a file

This might not be the best solution but it worked for me. If you get an Application Error message when trying to upload an image to a blog Post then you need to open up the secuirty on the images folder which is usually locatioed at App_Data\files. So what I did was added Everyone to have full access to that folder and I was then able to upload files. I had this problem a while back to but it came back, probably because I moved the website or upgraded BlogEngine.NET.

Hope this comes in handy for someone.

SQL Server: Can't remove an instance

I had an issue recently where I was not able to remove an instance of SQl Server, or so I thought. I kept on trying to remove the instance via Microsoft SQL Server 2014 RATHER THAN Microsoft SQL Server 2014 (64-bit). Once I selected the 64 bit option in Add-Remove Features I was able to finally gett rid of the instance I didn't want! Pretty dumb of me to not see the 64 bit option right away but there you go, sometimes you can't see the forest for the trees. 

SSRS: The permissions granted to user ' are insufficient for performing this operation

So you get this error when you try to deploy a report to SSRS from your Visual Studio Business Intelligence Studio: The permissions granted to user ' are insufficient for performing this operation. This can be the result of a few things.

1. The Folder that you are trying to deploy to does not exist or you don't have permission to create the folder.
2. You don't have permission for that folder!

BUT I'm the Admin, SA, big guy who owns everything so why the hell can't I deploy this dammed report!! It is more than likely that you have changed the permissions in the folder yourself and broken the parent inheritance and removed yourself at the same time. It happens! Or maybe someone else removed you. So how can you re-apply the permissions? You CAN’T do via the URL directly because that access is GONE. You need to launch SQL Server Reporting Services Configuration, then go to Report Manager URL and click on THAT LINK! Yeah, now you can reconfigure your messed up permissions.

Hope this helps someone else out one day!

Add Column to Default View Using PowerShell

Recently I had a request from a client to add a custom site collection column to all document libraries. This is pretty easy though the SharePoint UI of course, by creating a custom Site Column in the collection and adding it to the ‘Document’ content type.

However, in doing this the column is not added to the default view for any document libraries. This can be easily done using PowerShell using the script below. This adds the column to the default view in every document library throughout the entire site collection (referenced here).

$site = Get-SPSite “http://sharepoint.com”
$column = “Column”

$site | Get-SPWeb -limit all | ForEach-Object {

# Get all document libraries
$lists = $_.Lists | where  {$_.BaseType -eq “DocumentLibrary”}

# Loop libraries
for ($i = 0; $i -lt $lists.Count; $i++)
{

try
{

# Get current view
$view = $lists[$i].DefaultView

if($view)
{

# Delete if already exist
while($view.ViewFields.ToStringCollection().Contains($column))
{

$view.ViewFields.delete($column)
$view.Update()

}

# Add column
if(!$view.ViewFields.ToStringCollection().Contains($column))
{

$view.ViewFields.add($column)
$view.Update()

}

}

}
catch [Exception]
{

write-output (”  Error: ” + $_.Exception.ToString())

}

}

}

$site.Dispose()

You can also add views to a view by URL and view name for one specific view or list (a nice tip I found here). Here is another option by using GetViewFromUrl:

$spWeb = Get-SPWeb -Identity "http://mySharePoint"
$spView = $spWeb.GetViewFromUrl("/Lists/MyList/AllItems.aspx")
$spField = $spList.Fields["MyField"]
$spView.ViewFields.Add($spField)
$spView.Update()

You can also try to use SPList object as below:

$spList = Get-SPList -Url "http://mySharePoint/Lists/MyList"
$spView = $spList.Views["All Items"]
$spField = $spList.Fields["MyField"]
$spView.ViewFields.Add($spField)
$spView.Update()

Adding multiple columns to a view can also be done with PowerShell, and even create a new view and set it as the default view. This is really awesome if you want to leave the default ‘All Items’ view in tact, but create a new custom view and set it as default (found here):

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
$siteURL = "http://dev1share"
 $site = Get-SPSite($siteURL)
foreach($web in $site.AllWebs) {
$listCounter = $web.Lists.Count
 for($i=0;$i -le $listCounter;$i++) {
    $list = $web.Lists[$i]
     if($list.BaseType -eq "DocumentLibrary") {
     $newList = $web.Lists.item($list.ID);
  $viewfields = New-Object System.Collections.Specialized.StringCollection
   $viewfields.Add("DocIcon")
   $viewfields.Add("LinkFilename")
   $viewfields.Add("_UIVersionString")
   $viewfields.Add("Modified")
   $viewfields.Add("Created")
   $viewfields.Add("Editor")
   $viewfields.Add("FileSizeDisplay")
  [void]$newList.Views.Add("Detailed", $viewfields, "", 100, $true, $true)
   $newList.Update();
  $view=$newList.Views["Detailed"]
   $view.DefaultView = $true
   $view.Update()
 }
 }
$web.Dispose();
 }
 $site.Dispose();

 

SharePoint PowerShell Create View Based on Existing View

The following PowerShell script crawls the specified lists, copies the fields from the All Items views and creates a new view named "Created By Me" and sets it as default. Tested with SharePoint 2010 but should work with 2013 as well. Tested with list but not with Document Libraries.

I used this script as a base.

$ver = $host | select version

if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"} 

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 

{

 Add-PSSnapin "Microsoft.SharePoint.PowerShell"

}

 

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 

 

$web = Get-SPWeb -Identity "http://portal/sites/Requests"

$lists=$web.Lists["User Request", "Hardware Request",  "Employee Request"]

$SourceView="All Items"

$NewViewName="Created By Me"

$NewViewDefault=$true

 

 

foreach($list in $lists) {

 

 $view = $list.Views[$SourceView]

 $Viewfields = $list.Views[$SourceView].ViewFields.ToStringCollection()

 $viewRowLimit="100"

 $viewPaged=$true

 $viewDefaultView=$NewViewDefault

 

# Setting the Query for the View

 $viewQuery = "<ORDERBY><FIELDREF name="" false="" ascending=""></FIELDREF></ORDERBY><WHERE><EQ><FIELDREF author="" name=""><VALUE type="" integer=""><USERID type="" integer=""></USERID></VALUE></FIELDREF></EQ></WHERE>"

 $viewName = $NewViewName

 

# Finally – Provisioning the View

 $myListView = $list.Views.Add($viewName, $viewFields, $viewQuery, 100, $True, $False, "HTML", $False)

 

# You need to Update the View for changes made to the view

# Updating the List is not enough

 $myListView.DefaultView = $True

 $myListView.Update()

 $list.Update()

}

$web.Dispose()

How to create List using Power shell Script in SharePoint 2013

In this post we are going to see how to create Custom List from Power Shell in SharePoint 2013.

Create a SharePoint Custom List  Student Info with Columns
SNo    -  Number
SName  -  Text
Gender -  Choice
Photo  -  URL

#To which site u want to create the list
$spWeb=Get-SPWeb -Identity http://mySharePoint.ca

#List type or template
$spTemplate = $spWeb.ListTemplates["Custom List"]

#Get all the lists to the listcollection
$spListCollection=$spWeb.Lists

#adding the new list to the list collection
$spListCollection.Add("Studentlist","Studentlist",$spTemplate)

#get the path of subsite and sitecollecion
$path = $spWeb.url.trim()

#get the list to the list object
$spList = $spWeb.GetList("$path/Lists/Studentlist")

#adding the field type(Number) to the list
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Number
$spList.Fields.Add("SNo",$spFieldType,$false)

#adding the field type(Text) to the list
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text
$spList.Fields.Add("SName",$spFieldType,$false)

#adding the field type(choice) to the list
$choices = New-Object System.Collections.Specialized.StringCollection
$choices.Add("Female")
$choices.Add("Male")
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Choice
$spList.Fields.Add("Gender",$spFieldType,$false,$false,$choices)

#adding the field type(url) to the list
$spList.Fields.Add("Photo","URL",$false)

$Views = $spList.Views["All Items"]
$Views.ViewFields.Add("SNo")
$Views.ViewFields.Add("SName")
$Views.ViewFields.Add("Gender")
$Views.ViewFields.Add("Photo")

$Views.Update() - See more at: http://www.dotnetsharepoint.com/2013/06/how-to-create-list-using-power-shell.html#.U9_gPu90y9I

SharePoint 2010: Delete Service Application

Original Post: https://knowledge.zomers.eu/SharePoint/Pages/How-to-remove-a-SharePoint-2010-Service-Application.aspx

It may be necessary to remove one or more Service Applications in SharePoint 2010. It has happened to me quite a few times alread that the Search Service Application got corrupt and needed to be recreated. Unfortunately often this isn't as easy as using the standard delete function in the ribbon. Luckily there are other ways to get it done.

First method - The official way

  1. Open up Central Administration
  2. Click on the link Manage service applications under Application Management

    SP2010RemoveServiceAppCentralAdminLink.png
  3. Click the row with the Service Application you wish to delete so it will be marked in blue. Click on the Delete button in the ribbon to initiate the deletion process. Allow a couple of minutes for it to complete. If it doesn't seem to complete after waiting at most 15 minutes, proceed with method 2 below.

    SP2010RemoveServiceAppDeleteLink.png

Second method - The PowerShell backdoor

  1. If the first method does not work, you can try it using a direct PowerShell command. Open up a PowerShell window on your SharePoint 2010 server.
  2. Type the following line to enable the SharePoint PowerShell AddIn for the current window:

    Add-PSSnapin Microsoft.SharePoint.PowerShell

    SP2010RemoveServiceAppAddPSSnapin.png

  3. Type the following command to list all the Service Applications available on your farm. Look for the one being the Service Application you want to delete and copy its value in the Id column:

    Get-SPServiceApplication

    SP2010RemoveServiceAppGetSPServiceAppId.png
  4. Type the following command to remove the Service Application. Provide the Id retrieved at the previous step behind the Identity parameter:

    Remove-SPServiceApplication -Identity <id>

    SP2010RemoveServiceAppCommand.png
    If this also takes a long time (allow it at most 15 minutes to complete), proceed with method 3 below.

Third method - The dirty way

If the two options above fail, there is stil the dirty way of forcing removal:

  1. Follow steps 1 to 3 from method 2 to retrieve the Id of the Service Application you wish to remove, if you haven't got this Id yet.
  2. Enter the following command to instruct removal of the Service Application. Replace <id> with the Id retrieved at the previous step:

    stsadm -o deleteconfigurationobject -id <id>

    SP2010RemoveServiceAppStsadmCommand.png

    Allow a couple of minutes for this to complete. If also this method seems to be stuck, leave the process running, open up services.msc via the Windows start menu and restart the SharePoint 2010 Timer Windows service. That should get the command to complete after which the Service Application should be gone.

    SP2010RemoveServiceAppTimerService.png
  3.  
Thanks and I hope this helps someone else too.