Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:57:43+00:00 2026-05-24T13:57:43+00:00

I am using sharepoint 2010 and developing a visual web part. I had javascript

  • 0

I am using sharepoint 2010 and developing a visual web part. I had javascript functions on the ascx file and they all used to work file.Now I have moved them to a single javascript.js file and deployed it to the _layouts folder on server.

And I have put the below line on the ascx file to reference to that file

<script src="/sites/xxxxx/_layouts/customwebparts/javascript.js" type="text/javascript"> </script>

and then on the ascx.cs file and I am using the methods defined in this file for eg.,

      btnCancel.Attributes.Add("onclick", "{return Action(Cancel the form?)};");

But it is not working, it is not displaying the confimration box …Am I referencing the wrong way. Please help me ….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:57:44+00:00Added an answer on May 24, 2026 at 1:57 pm

    To reference a javascript file from within a SharePoint Visual Web Part you need to use the SharePoint:ScriptLink tag (example below):

    <SharePoint:ScriptLink ID="<someid>" runat="server" Name="/_layouts/...<Path>"></SharePoint:ScriptLink>
    

    I add a layouts mapped folder to my Visual Web Part project and place a scripts folder within the default folder, which I believe is the projects name. Following this model ensures that the javascript file is always kept up-to-date during deployment. The ‘Name’ property in the above tag is just the path to the javascript file relative to _layouts, so something like “/_layouts/ProjectName/Scripts/myjavascript.js”.

    As an FYI if you want to use CSS as well there is a SharePoint:CssRegistration tag as well. I find these are the 2 that I use the most.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a new Visual Web Part in VS 2010 (using Sharepoint Server 2010),
I'm developing a SharePoint 2010 Web Part (in C#) which needs to pull user
We are developing a system using SharePoint 2010 Foundataion. We would like to track
I have been developing pages and web parts in SharePoint 2007/2010 for the past
I am using SharePoint Foundation (Sharepoint 2010) to develop a workflow in Visual Studio
We are planning to create two sharepoint web applications using SharePoint 2010 Enterprise Edition.
I am currently developing a service using the SharePoint 2010 Client Object Model to
I've a file library on a sharepoint 2010. I'm using the Sharepoint library and
I have been working on some customisation for SharePoint 2010 using Visual Studio. My
Is it possible to develop for Sharepoint using Visual Studio 2010 pointing to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.