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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:32:39+00:00 2026-05-29T20:32:39+00:00

Is there way to associate a javascript function to a user control? Lets say

  • 0

Is there way to associate a javascript function to a user control? Lets say I have a name control written in .ascx. Can I define a client side function, lets say .clear(), that would be associated to name control. The clear function would clear all the elements of that control. I know I can create clear() javascript function but that would be global javascript function, not necessarily tied to name control. I want to tie the function to name control so that given that I have reference to name object, I should be able to simply call that function from that reference something like:

name.clear();

I know this can be done using MS Ajax framework but was wondering if I can do something like that using jQuery.

  • 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-29T20:32:41+00:00Added an answer on May 29, 2026 at 8:32 pm

    If by “clear” you mean set the value of text/password inputs, textareas and select elements to an empty string, and set radio and checkboxes to !checked, then you can do something like this:

    $("#someid").find('select,textarea,input[type="text"],input[type="password"]').val('');
    $("#someid").find('input:radio,input:checkbox').prop('checked',false);
    

    Or as a plugin:

    (function( $ ) {
      $.fn.clearChildren = function() {
        this.find('select,textarea,input[type="text"],input[type="password"]').val('');
        this.find('input:radio,input:checkbox').prop('checked',false);
        return this;
      };
    })( jQuery );
    
    $("#someid").clearChildren();
    

    Demo: http://jsfiddle.net/nnnnnn/AvfUz/

    (jQuery does have an “:input” selector that selects all selects, textareas and inputs, but you don’t want to set the value of checkboxes and radios so they need to be done separately.)

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

Sidebar

Related Questions

Is there a standard way to associate version string with a Python package in
is there way thats i can preselect an item when the page loads or
is there way how to get name ov event from Lambda expression like with
Is there any way to, with help of Javascript, list all cookies associated with
Independent from the HTML id attribute, is there a good way to define a
Is there any way to follow a URL in JavaScript without setting the document.location.href
Is there a way to make a null link besides these methods? <a href=javascript:;>Example</a>
Is there a way to get an associated icon in C# without using any
Is there quick way to get the ImageFormat object associated to a particular file
Is there a way on the CVS command line to list all files associated

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.