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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:57:00+00:00 2026-05-27T00:57:00+00:00

I have a user control which is called MyControl. And it is used in

  • 0

I have a user control which is called MyControl.

And it is used in the page for 3 times. So, there are 3 controls on the page.

I wrote the jquery function in that control which used ServerControl such as

function MyFunction(myName) {
    //some Ajax Call

    $("#<%= MyTextBox1.ClientID").val(DataFromAjax);
}

The problem is the page has 3 JQuery functions “MyFunction” and it is confused. My code run successfully if I used only 1 control on the page. But if it is more than one, the function conflicts with others.

I can’t move the function from the User Control to the Page because it references some serverside controls in the control.

Could you please advise me? Thanks all.

This is my JQuery Function.

function GetData(ADUser) {

        $.ajax({
            url: "/Health/Health.asmx/GetPersonData",
            data: "{ 'samAccount': '" + ADUser + "' }",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                var user = data.d;

                if (user != null) {

                    $("#cphContent_PersonalDetail1_txtFirstName").val(user.FirstName);
                    $("#cphContent_PersonalDetail1_txtLastName").val(user.LastName);
                    $("#cphContent_PersonalDetail1_txtTelephone").val(user.Telephone);
                    $("#cphContent_PersonalDetail1_txtEmail").val(user.Email);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        });

    }

This is how I bound it to the HyperLink Control.

if (!IsPostBack)
        {
            hlFill.Attributes.Add("onclick", string.Format("GetData('{0}'); return false;", GlobalSettings.UserADAccount));
}
  • 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-27T00:57:00+00:00Added an answer on May 27, 2026 at 12:57 am

    When you are calling “MyFunction” what is it you hoping to achieve? I mean that as are you trying to call it so that each javascript function in the three controls you have on the page executes concurrently so that the value is populated in each control from the Ajax callback.

    Or are you attempting to call a specific function in each control based on certain constraints?

    Each case has a different answer. For example, in the first case, this is purely theoretical but when you declare MyFunction can you continually build up the single function eg:

    if(MyFunction != null)
    {
        var oldFunction = MyFunction;
        MyFunction = new function(){ //new code here; oldFunction(); }
    
    }
    else
    {
        //Create it as you were but assign it to MyFunctino
    }
    

    If it’s the latter where you want to call each MyFunction based on specific constraints, is there anyway you can, for example take the Asp Controls id and append it to the function name so you create a unique function but then i am unsure how your calling it so this may or may not help.

    Edit:

    I understand a bit more about your problem now. I’m assuming at the moment that which ever one of your three controls that you click, it always executes the first one it finds so it just reloads the data into the first control?

    The crux of your problem is two fold:

    • There is no differentiation between the function name your controls outputs to the page.
    • The control values your setting in your function on success of ajax callback i’m assuming reference more than one html control on the page?

    From the JQuery function you posted, I can’t see exactly why you need to have this pasted into the control each time as I don’t see any server side variable output?

    My suggestion would be to create one function in the parent page that all your controls use. You explicitly state that you can’t due to server side variables, but if that is the case then modify your GetData() function to take in more parameters so that these define the context it should run in rather than from what control it is outputted from.

    Potentially pass in the controlid as a parameter to the jquery function as well which it could use as another selector to find the relevant html controls to populate the values on callback.

    Outputting a function multiple times should provoke the question “am i doing it right?” rather than “how can i get this to work?”.

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

Sidebar

Related Questions

Hi I have created a user control which is inside a folder called Controls
I have an ASP.NET Page that contains a User control called ReportCtrl (my own
I have a usercontrol called MyUserControl.xaml which dynamically adds another user control: UserControl myControl
I have a nested user control which appears on every single page. It contains
I have a user control, GridMasterControl which contains (amongst other things) another control called
I have the below LINQ method which gets called from a User Control and
I'm using VB.Net. I have a WPF User Control called NavigationPanel which I created
I have a custom WPF user control called a TimeoutPanel that I am trying
I have a user control which contains a textbox. I have a class called
I have a User Control which renders a simple drop downList into the page.

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.