when i try to call a javascript function in a dynamically loaded user control, it cannot find the function specified. I have a user control for organizationDetails.ascx. In there, I am using modal popup extender to get some information from the user and then i verify the address through google and suggests the proper format. I am trying to use a java script for a function called for onBlur of a textbox but the mozilla firebug says that the function is not defined, which is not the case. It would be great if someone can help me out here.
EDITED: The javascript is on the ascx page in the beginning and the usercontrol is loaded using the base class to show the organization details and edit them.
The ascx page has the following tags in the panel which is called by the modal popup.
<padrap:DropDownList ID ="ddlStateID"
onChange ="setContextKey2()"
runat ="server" />
<br />
<padrap:Label ID ="lCity"
Text ="City: "
AssociatedControlID ="tbrCity"
runat ="server"
CssClass ="col2"/>
<asp:TextBox ID ="tbrCity"
onBlur ="setContextKey2()"
runat ="server" />
<br />
<script type="text/javascript">
alert('i hate javascript');
var dependentBehaviors = [
'tbCity_ace_b'
];
var address = {};
function setContextKey2(){
//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;
address.postalCode = $get('<%=tbrPostalCode.ClientID%>').value; */
var contextStr = Sys.Serialization.JavaScriptSerializer.serialize(address)
var behavior = $find('tbCity_ace_b')
behavior.set_contextKey(contextStr);
var behavior2 = $find('tbPostalCode_ace_b')
behavior2.set_contextKey(contextStr);
}
</script>
The function for setContextKey2() is defined in the beginning of the page. Please let me know if you need some more information.
Thanks, Ratan