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

  • SEARCH
  • Home
  • 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 427417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:34:33+00:00 2026-05-12T19:34:33+00:00

I am building my first user control and I would like to package the

  • 0

I am building my first user control and I would like to package the javascript required for the control with the assembly so the end user does not have to worry about including dependencies. I’ve followed a tutorial from Scott Mitchell (https://web.archive.org/web/20210510023046/http://aspnet.4guysfromrolla.com/articles/080906-1.aspx) but I can’t seem to get it to work right.

Here is what I’ve done so far:

I’ve created a CollapsiblePanel.js file that contains the following function:

function TogglePanel(panelId) {
    //    $(panelId + ' .PanelContent').toggle();
    alert(panelId);
}

Under the properties panel I set the Build Action to “Embedded Resource”. This file resides in a scripts/ directory inside my class library project. The root namespace of my project is webstation.WebControls so if my understanding is correct I should be referencing the js file via “webstation.WebControls.scripts.CollapsiblePanel.js”

I’ve added the following line just before my class declaration for the custom control:

<Assembly: WebResource("webstation.WebControls.scripts.CollapsiblePanel.js", "text/javascript")>

I’ve overridden the OnPreRender event in my Custom Control and added the following:

Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)

    Page.ClientScript.RegisterClientScriptInclude("wsWebControlsCollapsiblePanel", _
                  Page.ClientScript.GetWebResourceUrl(Me.GetType(), "webstation.WebControls.scripts.CollapsiblePanel.js"))

    MyBase.OnPreRender(e)

End Sub

When I render my control I have a button with the function “TogglePanel(this.id);” in the onclick event, but when I click the button I get an error saying that the function is not defined. If anyone knows how I might begin using my embedded javascript I would really appreciate the help,

Mike

  • 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-12T19:34:33+00:00Added an answer on May 12, 2026 at 7:34 pm

    Found it,

    The problem was I included ‘scripts’ in the resource name so that I had “webstation.WebControls.scripts.CollapsiblePanel.js”

    I decided to try it so I had:
    “webstation.WebControls.CollapsiblePanel.js”

    and that did the trick.

    It’s a little confusing because all the documentation specifically states including the path as part of the naming convention, but perhaps I did something wrong when including a folder in the project.

    Mike

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

Sidebar

Related Questions

No related questions found

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.