locked
write javascript and get client ID RRS feed

  • Question

  • i am writing javascript and i want to get the id of html control, but changed when gets to sp2010, how to catch this id to work
    Monday, July 11, 2011 9:00 PM

Answers

  • Hi james if i am not wrong if you do something like that you will get code blocks,

    You only can do this if you add the command line in the aspx files in the 14/Hive folder not in the sharepoint Site, unless if you change the Web.config to accept code block to that page.

    Danny where you want to use this javascript?

    What i can recomend is create a Web control and get the ID of the control and inject the javascript to the page with the ID by that control.

     

     


    André Lage Microsoft SharePoint, CRM and Sybase Consultant
    Blog:http://aaclage.blogspot.com
    Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/
    • Proposed as answer by Sumit.Arora Tuesday, July 12, 2011 7:17 AM
    • Marked as answer by Shimin Huang Friday, July 22, 2011 8:52 AM
    Tuesday, July 12, 2011 6:49 AM

All replies

  • to get the id of the html control use ClientID paramter
    André Lage Microsoft SharePoint, CRM and Sybase Consultant
    Blog:http://aaclage.blogspot.com
    Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/
    Monday, July 11, 2011 9:17 PM
  • Just to add to Andre's answer: In your html you can do something like this:

     

    <script >
    var myId = "<%= MyControl.ClientID %>";
    </script>
    
    It will return the ClientID when the page / control is rendered.


    -James
    MCPD: SharePoint Developer 2010
    Posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, July 11, 2011 9:25 PM
  • Hi james if i am not wrong if you do something like that you will get code blocks,

    You only can do this if you add the command line in the aspx files in the 14/Hive folder not in the sharepoint Site, unless if you change the Web.config to accept code block to that page.

    Danny where you want to use this javascript?

    What i can recomend is create a Web control and get the ID of the control and inject the javascript to the page with the ID by that control.

     

     


    André Lage Microsoft SharePoint, CRM and Sybase Consultant
    Blog:http://aaclage.blogspot.com
    Codeplex:http://spupload.codeplex.com/http://simplecamlsearch.codeplex.com/
    • Proposed as answer by Sumit.Arora Tuesday, July 12, 2011 7:17 AM
    • Marked as answer by Shimin Huang Friday, July 22, 2011 8:52 AM
    Tuesday, July 12, 2011 6:49 AM
  • i want to use this in CEWP.
    Friday, July 15, 2011 8:19 AM