locked
Using Javascript in SharePoint designer RRS feed

  • Question

  • Hi,

    I am using SharePoint 2007. I created a custom list in Designer. I have added a textbox in the page. The Newform page is under the Master page.

    I have textbox as below:

    <asp:TextBox runat="server" id="TextBox1" onchange="javascript:SetMyData();" ></asp:TextBox>

    I am not able to find the head section, as it content page. where to write custom javascript functions in sharepoint designer?

    How to write custom javascripts in sharepoint designer 2007?

    Thank you

     

    • Moved by Mike Walsh FIN Thursday, April 29, 2010 2:49 PM spd q (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Thursday, April 29, 2010 12:52 PM

Answers

  • Hi Venkat,

      You can put your javascript in any of the content placeholder , for eample , in your case just put it after this:

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

    <script type=

    "text/javascript">

    </script>

    Regards,

     


    Manvir Singh Pamma
    • Marked as answer by Venkatzeus Thursday, April 29, 2010 1:50 PM
    Thursday, April 29, 2010 1:18 PM
  • Hi,

    I tried in the default.master page and it worked.

    But, could you please let me know the best practice to add javascript custom functions in sharepoint designer

    • Marked as answer by Venkatzeus Thursday, April 29, 2010 1:50 PM
    Thursday, April 29, 2010 1:49 PM

All replies

  • Hi Venkat,

      You can put your javascript in any of the content placeholder , for eample , in your case just put it after this:

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

    <script type=

    "text/javascript">

    </script>

    Regards,

     


    Manvir Singh Pamma
    • Marked as answer by Venkatzeus Thursday, April 29, 2010 1:50 PM
    Thursday, April 29, 2010 1:18 PM
  • Hi,

    I tried in the default.master page and it worked.

    But, could you please let me know the best practice to add javascript custom functions in sharepoint designer

    • Marked as answer by Venkatzeus Thursday, April 29, 2010 1:50 PM
    Thursday, April 29, 2010 1:49 PM
  • Hi Venkat,

       You can use _spBodyOnLoadFunctionNames.push in built sharepoint javascript function which gets invoked on page load and this can in turn call (for example) MyFunction.

    <script type=

    "text/javascript">

    _spBodyOnLoadFunctionNames.push(

    "MyFunction");

    function

     

    MyFunction()

    {

     

    }

    </script>

    Regards,

     


    Manvir
    Friday, April 30, 2010 7:01 AM