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 8868701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:19:40+00:00 2026-06-14T17:19:40+00:00

My custom server-side ajax control implements IScriptControl : GetScriptReferences GetScriptDescriptors First method sends javascript

  • 0

My custom server-side ajax control implements IScriptControl :

  • GetScriptReferences
  • GetScriptDescriptors

First method sends javascript files,second creates javascript objects based on some sended earlier .js files.

In my ‘AssembleyInfo’ file I added below lines and marked .js files in Properties explorer as ‘Embedded resourece’ :

    // this allows access to this files
    [assembly: WebResource("ProjectName.file1.js", "text/javascript")]

    [assembly: WebResource("ProjectName.file2.js", "text/javascript")]

Here is implementation of IScriptControl :

            public IEnumerable<ScriptReference>  
                GetScriptReferences()
            {
                yield return new ScriptReference("ProjectName.file1.js", this.GetType().Assembly.FullName);
                yield return new ScriptReference("ProjectName.file2.js", this.GetType().Assembly.FullName);
            }

            public IEnumerable<ScriptDescriptor>
                GetScriptDescriptors()
             {


                ScriptControlDescriptor descriptor = new ScriptControlDescriptor("ProjectName.file1", this.ClientID);
                //adding properties and events (I use "AnotherName" on the safe side to avoid potentional namespace problems           
                ScriptControlDescriptor descriptor2 = new ScriptControlDescriptor  ("AnotherName.file2", this.ClientID);
                //adding properties and events   

                yield return descriptor;
                yield return descriptor2;

            }

Here is parts of my .js files:

  • first file

    Type.registerNamespace("ProjectName");
    
    ProjectName.file1 = function (element) {
    .......
    .......
    }
    ProjectName.file1.registerClass('ProjectName.file1', Sys.UI.Control);
    
    if (typeof (Sys) !== 'undefined')
        Sys.Application.notifyScriptLoaded();
    
  • second file

    Type.registerNamespace("AnotherName");
    
    AnotherName.file2 = function (element) {
    ............
    ............
    }
    AnotherName.file2.registerClass('AnotherName.file2', Sys.UI.Control);
    
    if (typeof (Sys) !== 'undefined')
        Sys.Application.notifyScriptLoaded();
    

WHY CREATES ONLY FIRST OBJECT?

    yield return descriptor

MY ASPX HAS JAVASCRIPT THAT MUST CREATE SECOND.

IF I COMMENT ABOVE STATEMENT SECOND CREATES NORMALLY.

  • 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-06-14T17:19:41+00:00Added an answer on June 14, 2026 at 5:19 pm

    You can’t have multiple control definitions registered for the same DOM element – you’ll get a script error:

    Sys.InvalidOperationException: A control is already associated with the element.

    You’ll need to change one or both of your script classes to inherit Sys.UI.Behavior instead of Sys.UI.Control:

    YourType.registerClass("YourType", Sys.UI.Control);
    

    becomes:

    YourType.registerClass("YourType", Sys.UI.Behavior);
    

    You’ll also need to replace the relevant ScriptControlDescriptor with a ScriptBehaviorDescriptor:

    new ScriptControlDescriptor("YourType", ClientID);
    

    becomes:

    new ScriptBehaviorDescriptor("YourType", ClientID);
    

    Have a look at the extender control walk-through on MSDN for information on creating script behaviors:
    http://msdn.microsoft.com/en-us/library/bb386403%28v=vs.100%29.aspx

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

Sidebar

Related Questions

Possible Duplicate: Call ASP.NET Function From Javascript? In my custom ajax server-side control I
I'm building my first custom server control which inherits from CompositeControl The reason for
i am trying to make AJAX Call to ASP.Net Server Side Web service method
I have a Reapter control with a custom server side control inside of it.
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl
I have a custom server control which wraps a RadEditor (basically a textarea). I
I have custom server control contains templatefield when an out button clicked the field
On the OnPreRender of my custom server control, I am registering an alert to
I am building a modal box as a custom server control and I want
I currently have a file abc.htm in my Custom Server Control Project and it's

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.