Header

Thursday, 13 September 2012

How to create list Programmatically/VB.NET

This time i have created one list using VB.Net code
For this one i have created on function and passing one Foobar list that containg information that i need to upload in list .
In this function i m checking that if list is there then delete it and create new one .

Public Function GetSplist(ByVal ds As Generic.List(Of Foobar)) As SPList
        Dim web As SPWeb = SPContext.Current.Web
        web.AllowUnsafeUpdates = True
        'creating one object of splist with nothing value bcz this has no constractur
        Dim newList As SPList = Nothing
        Try
            If Not IsNothing(web.Lists("TempNewList")) Then
                Dim mylist As SPList = web.Lists("TempNewList")
                mylist.Delete()
                web.Update()
            End If
        Catch ex As Exception
        End Try
        'Here i am creating one list guid
        Dim newListGuid As Guid = web.Lists.Add("TempNewList", "This is my temp list, it will be removed when used", SPListTemplateType.GenericList)
        newList = web.Lists(newListGuid)
        If Not IsNothing(newList) Then
            newList.Fields.Add("SNo", SPFieldType.Text, False)
            newList.Fields.Add("FileRefNo", SPFieldType.Text, False)
            newList.Fields.Add("NavUrl", SPFieldType.Text, False)
         End If
        newList.Update()
        Dim newItem As SPListItem = Nothing
        For Each _item As Foobar In ds
            newItem = newList.Items.Add()
            newItem("SNo") = _item.SNo
            newItem("FileRefNo") = _item.FileRefNo
            newItem("NavUrl") = _item.NavUrl
            newItem.Update()
        Next
        web.AllowUnsafeUpdates = False
        Dim _mylist As SPList = newList
        Return _mylist
    End Function


Thanks And Regards,
Shailendra Kumar Singh

Tuesday, 11 September 2012

How to find web parts through vb.net


Hi Friedns,

Few days ago i was asked to hide Advaced search web part through one user control's button click.

i was socked how could i find that web parts, and really i wasted too much time to doing this simple task,
bcz i didnt know how to do :(
But we should not give up till get solution :D
and i finaly get solution.

There was a webpart zone in that i added advanced search web part and my Usercontrol through smartPartwithajax features.

so both are in same webpart zone.


Now this is simpl code that we use to find advanceSearchBox

 Public Sub setTab()
        Dim _controls As ControlCollection = Me.Parent.Parent.Controls
            For Each _cde As Control In _controls
                If _cde.GetType().ToString = "Microsoft.Office.Server.Search.WebControls.AdvancedSearchBox" Then
                    Dim _webpart As WebPart = CType(_cde, WebPart)
                    _webpart.Hidden = False
                    Exit For
                End If
           Next
End Sub

Call this function on ur button click on user control u will get solution .


Friday, 31 August 2012

How to work with SPGridView using Object Data Source.


 This post has been moved to this 

http://unique2026.blogspot.in/2013/08/how-to-work-with-spgridview-using.html













Thursday, 23 August 2012

How to activate SharePoint Taxonomy Fearture

In this article we will be seeing how to resolve "The Taxonomy feature (Feature ID "73EF14B1-13A9-416b-A9B5-ECECA2B0604C") has not been activated" error.

Sometimes when you try to use the Managed Metadata column type in SharePoint 2010 you may get an error saying "The Taxonomy feature (Feature ID "73EF14B1-13A9-416b-A9B5-ECECA2B0604C") has not been activated".

Activating the Taxonomy Feature using Power Shell:

    GO to Start menu.
    Go to SharePoint 2010 Management Shell and select Run as Administrator.
    In the command prompt, type each of the following commands.

    Enable-SPFeature -id 73EF14B1-13A9-416b-A9B5-ECECA2B0604C -URL http://<Server>

    <Server>- is the SharePoint server name.
    Now you have activated the Taxonomy Feature.

Activating the Taxonomy Feature using STSADM command:

    GO to Start menu.
    Go to SharePoint 2010 Management Shell and select Run as Administrator.
    In the command prompt, type each of the following commands.

    STSADM -o activatefeature -id 73EF14B1-13A9-416b-A9B5-ECECA2B0604C -url http://< Server > -force

    <Server>- is the SharePoint server name.
    Now you have activated the Taxonomy Feature.

Monday, 2 July 2012

How to prevent default button event



 
There are some situation when we need to fire only one event on Enter key and block others default event like a button.
Suppose we have a search box and that is available on all page through master page, In this condition where ever other button would be there we can face default event problem. So preventing this situation we can use preventDefault(); ... 

This is one code that can help u to understand this situation and u can get solution.


Here I bind a keypress event to one text box that id is txtUserName.

$('#txtUserName').bind('keypress', function(e) { if(e.keyCode==13){ if($("#txtUserName").attr("value")=="") { alert("please enter value to search"); } else { e.preventDefault(); location.href=getSPUrl() +"Search/Pages/results.aspx?k=" + $("#txtUserName").attr("value"); } } });


I think your looking for this only;...
Thanks and Regards,
Shailendra Kumar Singh


HOME BASED DATA TYPING JOBS AT www.online-home-jobs.com

Tuesday, 26 June 2012

How to fetch all user of SharePoint using Webserivec


$(function () {      
getLoggedInUser();
            function getLoggedInUser() {
                var soapEnv = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body><GetUserCollectionFromSite xmlns="http://schemas.microsoft.com/sharepoint/soap/directory/"/></soap:Body></soap:Envelope>';

                $.ajax({
                    url: "/_vti_bin/UserGroup.asmx",
                    type: "POST",
                    dataType: "xml",
                    data: soapEnv,
                    complete: processResult,
                    contentType: "text/xml; charset=\"utf-8\""
                });
            }
            function processResult(xData, status) {
             
                $(xData.responseXML).find("User").each(function () {
                   
                       if ($(this).attr("ID") == _spUserId) {
                        var uname = $(this).attr("Name");                      
                        alert(uname);
                    }
                   
                });
            }
        });




Just need to copy paste on script of Browser and u can get all user of SharPoint and based on current login u  can find the name of current user name ...............
So simple just try this.....:
Thanks And Regards,
Shailendra Kumar Singh

Monday, 18 June 2012

Hide Ribon in Sharepoint

 This post has been moved to this link

http://unique2026.blogspot.in/2013/08/how-to-hide-ribbon-in-sharepoint-2010.html