.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

javascript in sharepoint

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :SharePoint
Hello all, Am creating a webpart for sharepoint in c#.net,for which i have used two javascript files in .net ,can i able to deploy even javascript files into sharepoint !!suggest me Thanks in advance!!  

View Complete Post

More Related Resource Links

SharePoint Blog - Admin web part - newBlogPostOnClient JavaScript function


In the Admin Links web part in a default blog site, there are several links, the last one of which launches Microsoft Word and allows you to manage your posts from the Word blog template.  Cool feature.  But that web part is not configurable and I can't figure out how to duplicate that functionality.  It appears to have 3 GUIDS that are part of the function, part of the last parameter looks like the Posts list GUID, but it is concatenated with another GUID.   I want to either create my own web part or modify the XSL of the page to call the function, but I'm not sure what those other GUID parameters are.  Does anyone know?  The last one seems to be two of the separated by the # character.


Update SharePoint List item using UpdateListItem web service with javascript

I'm using the Custom_AddListMenuItems function in a CEWP to add a menu item to each list item to Archive that item. This is achieved by updating a choice field in the item to 'Archived'. I'm trying to do this using the web service UpdateListItem web service to update the item using Javascript, but I can not find the correct code that updates the list item. I'm using this code:     var ctx=currentCtx;     var ciid=currentItemID;     var xmlHttp=null;     if (confirm("Are you sure you want to Archive this item?"))     {         var soapRequest = '<?xml version="1.0" encoding="utf-8"?>'+             '<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>'+             '        <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'+         

JavaScript to get SharePoint DateTimeControl SelectedDate value?

Can anyone explain or give an example of how to get the SelectedDate value of a SharePoint datetimecontrol using JavaScript?  I have two of the datetimecontrols on a page and would like to capture the values and use them in query string variables when a button is clicked, but I cannot figure out the correct JavaScript syntax to get it.  The controls are set to DateOnly = True, so I have tried to reference them by the top-level ID (ie. DateTimeControl1) and by the ID of the textbox used for the date portion (ie. DateTimeControl1Date), but so far neither works.  Thanks in advance!Chanda

modify/override properties of default sharepoint modal dialogs (ex. editview.aspx) using javascript

Hello all, I would like to know how can I modify (override) some properties of the default sharepoint modal dialogs using Javascript. Ex. the size and location of editview.aspx. I while ago I asked a question about overriding the DialogResult in the display view dialog. I got an answer from Zach which looked like this:             sb.Append("<script type=\"text/javascript\">");             sb.Append(@"window.setTimeout(function () {");             sb.Append(@"if (window.frameElement && typeof(window.frameElement.overrideDialogResult) == 'function')");             sb.Append(@"{");             sb.Append(@"SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.DialogResult.OK', function () {");             sb.Append(@"window.frameElement.overrideDialogResult(SP.UI.DialogResult.OK); ");             sb.Append(@"});");             sb.Append(@"}");  

Javascript error when attempting to switch page layouts in SharePoint 2010

I hope I put this in the correct forum. I am experiencing the following error when attempting to change the layout of an existing SharePoint 2010 page. But it does not seem to happen on all page types, just publishing pages. This error is happening on both the development server and both test servers. I have look in to the logs, since if it a javascript error there was nothing, which would be expected but I had to try. I have look at the cui.js file but was unable to spend enough time trying to figure out what exactly is going on in this file. Error being received ... Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3) Timestamp: Tue, 7 Sep 2010 21:10:54 UTC Message: Object required Line: 2 Char: 6422 Code: 0 URI: http://devintranet2010.myconexus.ca:85/_layouts/cui.js?rev=wvoVpqlQb30nGo4DjDk8Kg%3D%3D   If anyone has any ides or can point me in a direction that will allow me to productively continue my investigation, the information would be greatly appreciated. Regards Kyle

Execute Javascript from Sharepoint Event Handler

Hello, I want to execute a sample java script function from itemadding event of sharepoint event handler.  How can i achieve this? Please Help.   Thanks in Advance

Sharepoint Javascript help.

On my sharepoint site, I've added a custom aspx page to my sharepoint site. Now I can't access my textbox control through javascript. Sometimes it will work and other times, it doesn't. Any help. Example is provided below:   document.getElementById('<%=lname%>').value <input type="text" maxlength="75" size="35" name="lname" id="lname" runat="server" />   can anyone help?   Thanks,

How do I add an external javascript and CSS to the head of a Sharepoint page?

I am a web designer and I was asked to design a page for our internal sharepoint server. I created a spry page using Dreamweaver CS5, and I need to add the .js and .css to the head of the sharepoint document. I created the sharepoint page, and added my html code to the html webpart, the content displays, but I need to add the external files to the <head> tag so the content displays correctly. I tryed to open the page in SP Designer 2007, but I can't edit or add to the head tag. Help

How to update JavaScript in SharePoint Ribbon Elements.xml file?


I created Elements.xml file that added button to Ribbon of Web Part page.
I created <CommandUIHandler tag and put JavaScript into CommandAction.
Everything works.

I inserted changes to JavaScript and built and deployed project in VS2010.
The button function was not changed the previous JavaScript was used. I uninstalled feature and rebuilt and redeployed project. The button functionality was not changed again.

What I have to do that JavaScript changes work in CommandAction?

Thank you in advance for any help.

Boris Nossov

Sharepoint 2007 View, append url with Javascript and reload page


Hi all. I have an odd requirement.

I have created a number of views for a custom list I have created. I need to be able to filter these lists by what "Quarter" we are currently in (Jan-Mar - 1; Apr-Jun - 2; Jul Sep - 3; Oct-Dec -4) compared to when the item was created (i have a calculated column that uses the created date to have the quarter). Each view is a new page (as you have created a view from within Shaarepoint)

I haven't been able to work out how to do this in the CAML query (as I can't figure out how to reference todays date in CAML).

With this out of the question, I then tried to use the Today column hack, but as this isn't dynamic, this doesn't work.

My final efforts now revolve around using a basic javascript function to append my url with the following:

?FilterField1=CreatedQuarter&FilterValue1="+ currentQuarter;

Add items to sharepoint custom list using javascript with webservices



Here is the code snippet i was trying to insert item to sharepoint list but i conn't please help me what is wrong in my code and modify it.


function addlistitem(item)


var xmldoc;

var batch;

var FeedbackHTTP;

var ListName = 'Suggestions';

//The batch variable builds up the XML that we are going to submit to the SharePoint list via the SharePoint web service

batch = "<batch><method id='1' cmd='New'><field name='Title'>" + item + "</field></method></batch>";

xmldoc = '<?xml version="1.0" encoding="utf-8"?><soap:envelope xsi="http://www.w3.org/2001/XMLSchema-instance" xsd="http://www.w3.org/2001/XMLSchema" soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:body><updatelistitems xmlns="http://schemas.microsoft.com/sharepoint/soap/">'

xmldoc = xmldoc + '<listname>' + ListName + '</listname>';



xmldoc = xmldoc + '<updates>' + batch + '</updates></updatelistitems></soap:Body></soap:Envelope>';

FeedbackHTTP = new ActiveXObject("MSXML2.XMLHTTP.3.0");


Start a SharePoint 2010 WorkFlow using JavaScript



I need to start a SharePoint WorkFlow using JavaScript, the JavaScript would be in bespoke Asp.Net page. Any ideas ?



javascript not working in sharepoint Public IPhosted site ?




Can AnyBody guide me why Javascript is not functioning in my hosted site with Public IP and i had 3rd party tools using the javascript which they were displaying but functionality.


Pls help me to resolve this !!!!

Thanks in Advance !!! Cheers !!! Praveen Mandalapu

Using javascript and ActiveX in developing web part for sharepoint 2010


I am trying to develop a webpart that uses javascripts to access an ActiveX. The activex is a clinet side component which is accessed by javascripts to to open graphics file and display it.

I put activeX inside the _layout directory.

Please is there any help on how we refrence and includes javascripts code files and the ActiveX inside the webpart? I use VS2010 and tried to build a webpart  but it seems the javascripts didnt run and am sure there is something missing.

Thanks alot for any help.

read and print sharepoint list information using javascript



i am working on a form right now, user's inputs will be stored in a sharepoint list. after user click submit, it will display a thankyou panel, and send a email to me showing user's input. on the thankyou panel, there is a button, if user click it, it will open a new window and display exactly the same thing in email, so that user can check if they input the right thing.

i did this part using javascript, the window.open method. and i wrote html code in it, using window.document.write method.

i wrote a read from sharepoint list function, i dont know if it is working, but my question is how can i call this function in javascript since it will be a client side programming.

my readfromlist code is here:

public void readFromList()
             SPSite oSiteCollection = SPContext.Current.Site;
             SPList oList = oSiteCollection.AllWebs["something"].Lists["somelist"];
             SPView oListView = oList.Views["All Items"];
             SPListItemCollection collectListItems = oList.GetItems(oListView);

             foreach (SPListItem oListItem in collectListItems)
                 txtFirstName.Text = SPEncode.HtmlEncode(oListItem["First Name"].ToString()) + "<BR>";

Item update in the sharepoint list using web service with javascript



I am using below code for web services with javascript


function CreateListItem(Title)



    var soap1 = createEnvelope(Title);


    var ws = new ActiveXObject("Microsoft.XMLHTTP");    

      if(ws == null) 

       return null;





    ws.setRequestHeader("Content-Type", "text/xml; charset=utf-8");            







  function createEnvelope(Title)


     var batch;

var xmldoc;    

var ListName = 'S

Adding a JavaScript to SharePoint Page with SharePoint Designer


I am trying to add a javascript to a single SharePoint page. This script will only be used on this one page so I do not want to put it in the master page. I saved the the scritp to a document library on my site. Using SharePoint Designer, I opened the page on which the script should reside. I put the tag script tag at the first place I could. When I save the page, I get this error:

Content in the embedded form field may be changed by the server to remove unsafe content. Do you want to reload your page to see the results of the save?

After clicking Yes, the script tag is gone. How do I add this script to my page?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend