Note that there are some explanatory texts on larger screens.

plurals
  1. POConflict JQuery function in the ASP.Net User Control
    primarykey
    data
    text
    <p>I have a user control which is called MyControl.</p> <p>And it is used in the page for 3 times. So, there are 3 controls on the page.</p> <p>I wrote the jquery function in that control which used ServerControl such as</p> <pre><code>function MyFunction(myName) { //some Ajax Call $("#&lt;%= MyTextBox1.ClientID").val(DataFromAjax); } </code></pre> <p>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.</p> <p>I can't move the function from the User Control to the Page because it references some serverside controls in the control.</p> <p>Could you please advise me? Thanks all.</p> <p>This is my JQuery Function.</p> <pre><code>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) { } }); } </code></pre> <p>This is how I bound it to the HyperLink Control.</p> <pre><code>if (!IsPostBack) { hlFill.Attributes.Add("onclick", string.Format("GetData('{0}'); return false;", GlobalSettings.UserADAccount)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload