Header

Tuesday, 13 December 2011

SharePoint page mode(Edit/Not Edit)


We can check page mode by this value.
If it is one then page is in edit mode.
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
document.forms[0].elements["MSOLayout_InDesignMode"].value
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Thanks and Regards

Saturday, 3 December 2011

Insert data using SPAPI

We need to call this function for adding content in lis..
function Feedbackadd()
   {
            var regad_var = $("#regad1 option:selected").text();
            \\ Get the value from one DropDown list that id is regad1
            var sub_var = $("#sub1").attr('value'); 
           \\ Get the value from one text box that id is sub1.
            var name_var = $("#name1").attr('value');
            \\ Get the value from one text box that id is name1.
            var email_var = $("#email1").attr('value');
            \\ Get the value from one text box that id is email1.
            var msg_var = $('#textareamsg1').val();
             \\ Get the value from one text box that id is textareamsg1.
            var lists = new SPAPI_Lists('listLocationt');
            \\ Give the location of document where Feedback list is there.
            var res = lists.quickAddListItem('Feedback', { Title:sub_var, Regarding:regad_var, Subject:sub_var, Name:name_var, Email:email_var, Message:msg_var });
      
         if (res.status == 200)
            {
                alert('Thank you for Feedback.');
              }
            else
            {
                alert('Unexpected error.');
            }
          
        }


Thanks ....................:-) 

How to Register User Control

There are 2 way to register a user control in asp page.
  1. Register in asp page on top
  2. Add in web.config file
To register a user control in aspx page we need to add
<%@ Register TagPrefix="adms" TagName="Student" src="~/StudentDetails" %>

We can register our user control in web.config file. By this way we can use our user control anywhere in our solution, no need to register on every page manually. For doning this we need to modify our web.config file

<?xml version="1.0"?>
  <configuration>
    <system.web>
   <pages>
     <controls>
    <add tagPrefix="adms" src="~/Controls/StudentDetails" tagName="Student"/>
    <add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
     </controls>
   </pages>
    </system.web>
  </configuration>

***********************
But when we register our user control in web.config file we need to check location of user control bcz we cant keep both (web.config, user control) at same locaion
  ******************

If want to use this user control we can use like below
<adms:Student id="show" runat="server" />


Thanks

Friday, 2 December 2011

Position Change on Hover

For doing this we need two image. 
Fist one will be visible bydefault and scecond will appear on hover.
Now we need to add both image in single image, on top part add default image and in bottom part add hover image.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#onHover_adms a{
background:url("previous.png") 0 0 no-repeat;
font-size:25px;
padding-right:18px;
}
#onHover_adms a:hover{
background-position:0px -29px;
}

<div id="onHover">
<a href="#">&nbsp;</a>
</div>

Thanks........................

Friday, 25 November 2011

How to Decode URL

//////////////////////////////////////////////////////////

var new1="http://www.abc.com/About%20Us/Pages/Default.aspx";
var newe=decodeURI(new1);
alert(newe);
//////////////////////////////////////////////////////////


This is for encoding the url
var newe=encodeURI(new1);

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
We can decode url or Querystring by server side code

Dim _queryString As String = HttpUtility.UrlDecode(Request.QueryString().ToString())

now _queryString will hold decoded value
Thanks.....

Monday, 24 October 2011

How to get User Details in sharepoint.

////////////////////////////////////////////////////////

  1. Dim user As SPUser = SPContext.Current.Web.CurrentUser

  2. Checking is current login is admin or not?

    SPContext.Current.Web.CurrentUser.IsSiteAdmin

  3. This will give, all group, which are present in current site

    SPContext.Current.Web.Groups

    This will give the group name of current user

    SPContext.Current.Web.CurrentUser.Groups

  4. Here i m getting all user and add in one DropDownList

    Dim websp As SPWeb = SPContext.Current.Site.RootWeb
    Dim users As SPUserCollection = websp.AllUsers
    For Each i As SPUser In users
    dropdownlist1.Items.Add(CStr(i.Name))




How to get connected to a site in sharepoint.

////////////////////////////////////////
How to get connected to a site in sharepoint.
////////////////////////////////////////
1)
     Dim oWebsite As SPWeb = SPContext.Current.Web
2)
     Using oWebsiteRoot As SPWeb = SPContext.Current.Site.RootWeb
                ...
     End Using
3)
     Using oWebsite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL")
  ...
      End Using
4)
      Using oSiteCollection As New SPSite("http://server_name/")
         Using oWebsite As SPWeb = oSiteCollection.OpenWeb("Website_URL")
             Using oWebsiteRoot As SPWeb = oSiteCollection.RootWeb
                  ...
             End Using
         End Using
      End Using
5)
      Dim myWeb As SPWeb = SPContext.Current.Web
      Debug.WriteLine("MyWeb lists : ")
                        For Each aList As SPList In myWeb.Lists
                              Debug.WriteLine("************************************")
                              Debug.WriteLine("list Title (Display Name): " & aList)
                              Debug.WriteLine("list Title (Display Name): " + aList.Title)
                              Debug.WriteLine("list Root Folder Name: " + aList.RootFolder.Name)
                              Debug.WriteLine("************************************")
                         Next

Sunday, 23 October 2011

How to send email using Javascript....

How to send E-mail with subject


This is a small function that is use for simply sending msg with subject.............

function sendMail() {

     var link  = 'mailto:?subject=Here You can put ur Subject&body='; 
 
     var curntLoc=window.location.href;
     link +=escape(curntLoc);
  window.location.href = link;
   // window.location.href = link;
}

Thursday, 20 October 2011

Hot to get Current user name using SPAPI

 This post has been moved to this

http://unique2026.blogspot.in/2013/08/hot-to-get-current-user-name-using-spapi.html


Get Query String Value

How to get value from QueryString.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
function querySt(elementName) {
                curulr = window.location.search.substring(1);
                qryElement = curulr.split("&");
                for (i=0;i< qryElement.length;i++) {
                                spltdElement = qryElement [i].split("=");
                                                if (spltdElement[0] == elementName) {
                                                return spltdElement[1];
                                                }
                                }
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
This is very small function but very power full. You need to pass query string element name and if it is in query string it will return the value what it is holding.
Here is an example…
I want to get value of ID from query string using this function.
var _newID= querySt(“ID”);
alert(_newID);
now I will get one alert with value of id…..

How to start with SPAPI in Sharepoint

 This post has moved to this link.

http://unique2026.blogspot.in/2013/08/how-to-start-with-spapi-in-sharepoint.html

Wednesday, 19 October 2011

How to change web parts Title Style


<style>

.ms-WPHeader TD[title^='Testing'] {
HEIGHT: 50px;
BACKGROUND: url(/HomePage-Images/announcements_1px.png);
}
.ms-WPHeader TD[title^='Testing'] SPAN:first-child {
PADDING-LEFT: 55px;
WIDTH: 65px;
PADDING-TOP: 0px;
}
.ms-WPHeader TD[title^='Testing'] H3 {
PADDING-BOTTOM: 0px;
 MARGIN: 0px;
PADDING-LEFT: 0px;
PADDING-RIGHT: 7px;
HEIGHT: 55px;
COLOR: black;
FONT-SIZE: 1.2em;
PADDING-TOP:0px;
BACKGROUND: url(/HomePage-Images/announcements.png) no-repeat left top;
}
</style>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.ms-WPHeader TD[title^='Testing']
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
By using -----TD[title^='Testing']------  i m trying to find web part whose Title is Testing . It may be your is different.
After that i m giving background image for title. You can give any color.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.ms-WPHeader TD[title^='Testing'] SPAN:first-child
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This one i m using for putting style sheet for title(Testing" ). It may u need to set padding top for alignment.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ms-WPHeader TD[title^='Testing'] H3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I m using this for left side image