I have a ascx page which has a textbox whose onBlur property is set to use a js. My problem is that if the js is kept in the ascx page itself, it does not work at all. So I made a new js file and put the whole script in there. Now, the function needs access to texts of textbox and the ddl to be able to set the context key. How do I pass the values to the js file. Below is my ascx code and the js file code.

ASCX CODE:

Code:
<asp:ScriptManagerProxy ID="scriptManagerProxy1" runat="server">
                            <Scripts>
                                <asp:ScriptReference Path="~/file/js/ContextKey/setContext.js" />
                            </Scripts>
                        </asp:ScriptManagerProxy>
                            
                        <asp:UpdatePanel        ID="updatePanelCountry"
                                                runat="server">
                                                
                            <ContentTemplate>
                                                
                                <padrap:Label           ID                  ="lCountry"           
                                                        runat               ="server" 
                                                        AssociatedControlID ="ddlCountryID" 
                                                        CssClass            ="col2"
                                                        Text                ="Country"/>
                                <padrap:DropDownList    ID                  ="ddlCountryID"
                                                        onChange            ="setContextKey()"
                                                        runat               ="server"  />
                                <br />
                                                         
                                <padrap:Label           ID                  ="lState"
                                                        Text                ="State: " 
                                                        runat               ="server"
                                                       
                                                        AssociatedControlID ="ddlStateID" 
                                                        CssClass            ="col2"/>                       
                                                        
                               
                                                         
                                <padrap:DropDownList    ID                  ="ddlStateID"
                                                        onChange = "setContextKey()"
                                                        
                                                        runat               ="server"   
                                                         />

                                            <br />                  
                                <padrap:Label           ID                  ="lCity"
                                                        Text                ="City: "
                                                        AssociatedControlID ="tbrCity" 
                                                        runat               ="server" 
                                                        CssClass            ="col2"/>                       
                                                        
                                                         
                                <asp:TextBox            ID                  ="tbrCity"
                                                        onBlur              ="setContextKey()"
                                                        
                                                        runat               ="server"  />                        
                                                            
                                    
                                    <br />
                                
                                                                                 
                                <ajax:AutoCompleteExtender
                                                    ID                  ="tbCity_ace"
                                                    runat               ="server" 
                                                    TargetControlID     ="tbrCity" 
                                                    ServicePath         ="~/svc/cascades.asmx" 
                                                    ServiceMethod       ="GetCityCompletionList"
                                                    DelimiterCharacters =";,:"
                                                    CompletionInterval  ="100"
                                                    CompletionSetCount  ="10"
                                                    EnableCaching       ="true"
                                                    BehaviorID          ="tbCity_ace_b"
                                                    MinimumPrefixLength ="1" />
                              
                                <ajax:CascadingDropDown
                                                    ID              ="cddCountry"
                                                    BehaviorID      ="cddCountry_Behavior"
                                                    runat           ="server"
                                                    TargetControlID ="ddlCountryID"
                                                    Category        ="Country"
                                                    PromptText      ="- Select -"
                                                    LoadingText     ="Loading..."
                                                    UseContextKey   ="true"
                                                    ServicePath     ="~/svc/cascades.asmx"
                                                    ServiceMethod   ="GetCountriesWithContextKey" />
                                <ajax:CascadingDropDown
                                                    ID              ="cddState"
                                                    BehaviorID      ="cddState_Behavior"
                                                    runat           ="server"
                                                    TargetControlID ="ddlStateID"
                                                    ParentControlID ="ddlCountryID"
                                                    Category        ="State"
                                                    PromptText      ="- Select -"
                                                    LoadingText     ="Loading..."
                                                    UseContextKey   ="true"
                                                    ServicePath     ="~/svc/cascades.asmx"
                                                    ServiceMethod   ="GetStatesWithContextKey" />                    
                                
                            </ContentTemplate>
                            
                    </asp:UpdatePanel>
                    </fieldset>
The JS file:

Code:
var dependentBehaviors = [
            'tbCity_ace_b'
        ];

var address = {};
function setContextKey() {
    //some javascript
    address.addressLine1 = $get('<%=tbrAddressID1.ClientID %>').value;
    address.addressLine2 = $get('<%=tbrAddressID1.ClientID %>').value;
    address.addressLine3 = $get('<%=tbrAddressID1.ClientID %>').value;
    address.countryISO2 = $get('<%=ddlCountryID.ClientID%>').value;
    address.stateCode = $get('<%=ddlStateID.ClientID%>').value;
    address.city = $get('<%=tbrCity.ClientID%>').value;
    

    var contextStr = Sys.Serialization.JavaScriptSerializer.serialize(address)

    var behavior = $find('tbCity_ace_b')
    behavior.set_contextKey(contextStr);

    
}