Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I mean to create a generic user control to use it in various places. It has a button,a hyperlink and a autocomplete textbox. When I try to use this user control on multiple occassions in the same aspx page, the autocomplete box doesn't work as desired.It is replaced by the values of the most latest variables being passed. I am using a Javascript function to call this AJAX autocomplete box.Below is the Javascript code used to call the AJAX autocomplete box.This javascript function is placed in the GenereicHierarchy.ascx page.
****************************************************************************
JavaScript
function KeySelectedForHierarchy(source, eventArgs) {
debugger

var controlName = '<%=Session["controlName"]%>';
var execOrgSummary = '<%=Session["execOrgSummary"]%>';
var channelControlName = '<%=Session["channelControlName"]%>';
var channelOrgSummary = '<%=Session["channelOrgSummary"]%>';
var hierarchyValue = eventArgs.get_value();
var hierarchyText = eventArgs.get_text()


//Calling GetHeirarchy for Finding whether its a Hierarchy summary or function or Hierarchy detail.
var hierarchy = GetHeirarchy(hierarchyText);
//when user selectes Hierarchy summary, its value and text added in hidden.
if (hierarchy == execOrgSummary) {
    if (document.getElementById("filter_" + controlName + "_hiddenSummary").value == "") {
        document.getElementById("filter_" + controlName + "_hiddenSummary").value = hierarchyValue + "," + hierarchyText;
    }
    else {
        var hiddenHierarchySummary = document.getElementById("filter_" + controlName + "_hiddenSummary").value;
        if (hiddenHierarchySummary.indexOf(hierarchyValue) < 0) {
            document.getElementById("filter_" + controlName + "_hiddenSummary").value =
                     document.getElementById("filter_" + controlName + "_hiddenSummary").value + "|" + hierarchyValue + "," + hierarchyText;
        }
    }
}
    //channel org summary
else if (hierarchy == channelOrgSummary) {
    if (document.getElementById("filter_" + channelControlName + "_hiddenDetail").value == "") {
        document.getElementById("filter_" + channelControlName + "_hiddenDetail").value = hierarchyValue + "," + hierarchyText;
    }

    else {
        var hiddenHierarchyDetail = document.getElementById("filter_" + channelControlName + "_hiddenDetail").value;
        if (hiddenHierarchyDetail.indexOf(hierarchyValue) < 0) {
            document.getElementById("filter_" + channelControlName + "_hiddenDetail").value =
                     document.getElementById("filter_" + channelControlName + "_hiddenDetail").value + "|" + hierarchyValue + "," + hierarchyText;
        }
    }

}

//fuction used for spliting the text.
function GetHeirarchy(hierarchyText) {
var hierarchys = new Array();
hierarchys = hierarchyText.toString().split('[');
return hierarchys[1].toString();
}

*****************************************************************************
The session variables are being passed on from the GenericHierarchy.ascx.cs page. On every occassion channelControlName and channelOrgSummary are displayed in the autocomplete textbox irrespective of what I pass in controlName and exeOrgSummary. While debugging, I tried to put the whole above function in an external Jscript file and call the Jscript file in the GenericHierarchy.ascx page, but it didn't solve the issue. Am I missing something? Suggestions and insights will be highly helpful.

-Anurag
Posted
Comments
Anurag Sinha V 23-Dec-12 23:39pm    
Hi..can anybody assist me on the above scenario..a havin a hard time going thru it..Any pointers or suggestions will b highly appreciated...
-Anurag

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900