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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:26:35+00:00 2026-05-11T05:26:35+00:00

I am trying to understand a script generated by Asp.Net Ajax Toolkit, which is

  • 0

I am trying to understand a script generated by Asp.Net Ajax Toolkit, which is currently giving an ‘object expected’ (error goes away if I place my PopupControlExtender in an update panel).

document.getElementById('ctl00_ValidationSummary1').dispose = function() {     Array.remove(Page_ValidationSummaries, document.getElementById('ctl00_ValidationSummary1')); } (function() {var fn = function() {AjaxControlToolkit.ModalPopupBehavior.invokeViaServer('ctl00_c1_componentCategoryListUC_componentCategoryGrid_modalPopupExtender', true); Sys.Application.remove_load(fn);};Sys.Application.add_load(fn);})(); 

What I see here is:

someobject.someevent = function() {     dosth; } /* Get ready, I am about to do sth crazy ... */ (function() { dosth; })(); /* you did what? */ 

What does this syntax mean?

Edit: I am specifically curious about (function () { … })() coming immediately after another function’s ending }.

Edit: Turns out, ajax guys forgot to place a semicolon after the event handler assignment.

  • 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. 2026-05-11T05:26:36+00:00Added an answer on May 11, 2026 at 5:26 am

    The

    (function() { dosth; })();

    syntax declares an anonymous function, and then executes it immediately. It’s equivalent to doing this:

     var myFun = (function() { dosth; });  myFun();

    but without the temporary variable.

    Broadly speaking this is similar to just executing whatever dosth is; but creating a function object introduces a new scope for variables (due to the closure), and thus this is often used to work around issues with scoping.

    In the specific case you’ve quoted, I don’t see any reason why this would be particularly necessary. However it could be done like this for two reasons – either the final Javascript itself is generated by some automatic process that can’t tell whether the closure is needed; or it was written by a human who decided to always wrap things in functions to be safe.

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

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I am trying to adapt a perl script that is used to generate a
Can anyone explain to me the benefits of using XML-RPC over a straight HTML
I am implementing web services for a PHP application and am trying to understand
I am trying to take one step towards optimizing a 90GB+ table: Old Table

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.