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.


<asp:ScriptManagerProxy ID="scriptManagerProxy1" runat="server">
                                <asp:ScriptReference Path="~/file/js/ContextKey/setContext.js" />
                        <asp:UpdatePanel        ID="updatePanelCountry"
                                <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 />
                                                    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" />
                                                    ID              ="cddCountry"
                                                    BehaviorID      ="cddCountry_Behavior"
                                                    runat           ="server"
                                                    TargetControlID ="ddlCountryID"
                                                    Category        ="Country"
                                                    PromptText      ="- Select -"
                                                    LoadingText     ="Loading..."
                                                    UseContextKey   ="true"
                                                    ServicePath     ="~/svc/cascades.asmx"
                                                    ServiceMethod   ="GetCountriesWithContextKey" />
                                                    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" />                    
The JS file:

var dependentBehaviors = [

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')