<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="NameLabelsTop.ascx.vb" Inherits="QuadMaxRedesign.Name_Addr_LabelsTop" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<script type="text/javascript">
var objHttp;
var objXmlDoc;
function getDataFromWS(methodName, dataSetName, wsParamValue, wsParamName)
{
// create the XML object
objXmlDoc = new ActiveXObject("Msxml2.DOMDocument");
if (objXmlDoc == null)
{
alert("Unable to create DOM document!");
} else {
// create an XmlHttp instance
objHttp = new ActiveXObject("Microsoft.XMLHTTP");
// Create the SOAP Envelope
strEnvelope = "<soap:Envelope xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xsd=\"http://www.w3.org/2001/XMLSchema\"" +
" soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
" <soap:Body>" +
" <" + methodName + " xmlns=\"http://tempuri.org/Webservice\">" +
//" <" + wsParamName + "> 44512 </" + wsParamName + ">" +
" </" + methodName + ">" +
" </soap:Body>" +
"</soap:Envelope>";
// Set up the post
objHttp.onreadystatechange = function(){
// a readyState of 4 means we're ready to use the data returned by XMLHTTP
if (objHttp.readyState == 4)
{
// get the return envelope
var szResponse = objHttp.responseText;
// load the return into an XML data island
objXmlDoc.loadXML(szResponse);
if (objXmlDoc.parseError.errorCode != 0) {
var xmlErr = objXmlDoc.parseError;
alert("You have error " + xmlErr.reason);
} else {
switch(dataSetName)
{
case "CityStateDS":
processCityState();
break;
}
}
}
}
var szUrl;
szUrl = "http://localhost:49646/QuadmaxWebService.asmx/" + methodName;
//If using Query String instead of param in soap method
if (wsParamValue != null)
{
szUrl += "?" + wsParamName + "=" + wsParamValue;
}
//alert(szUrl);
// send the POST to the Web service
objHttp.open("POST", szUrl, true);
objHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
objHttp.send(strEnvelope);
}
}
function getCity()
{
var Elm = document.getElementById("txtZip");
var zip = Elm.value;
var func = "getDataFromWS('GetCityState', 'CityStateDS','" + zip + "', 'Zip' )";
window.setTimeout(func,1);
}
function processCityState()
{
// get an XML data island with the category data
objNodeList = objXmlDoc.getElementsByTagName("Cities");
// walk through the nodeList and populate the dropdown
for (var i = 0; i < objNodeList.length; i++)
{
var dataNodeList;
var textNode;
var valueNode;
dataNodeList = objNodeList[i].childNodes;
valueNode = dataNodeList.item(0);
textNode = dataNodeList.item(1);
document.getElementById("TabContainer1_TabPanel4_uc1_txtCity").innerText = valueNode.text;
document.getElementById("TabContainer1_TabPanel4_uc1_txtState").innerText = textNode.text;
}
}
</script>
<asp:Label ID="lblName" Text="Name:" runat="server" Font-Size="Smaller"></asp:Label>
<br />
<asp:TextBox ID="txtFirstName" runat="server" ></asp:TextBox>
<asp:TextBox ID="txtLastName" runat="server" ></asp:TextBox>
<asp:TextBox ID="txtMI" runat="server" Width="32px" MaxLength="1"></asp:TextBox>
<br />
<asp:Label ID="lblAddress" runat="server" Text="Address:" Font-Size="smaller"></asp:Label>
<br />
<asp:TextBox ID="txtAddress1" runat="server" Width="350px" ></asp:TextBox>
<br />
<asp:TextBox ID="txtAddress2" runat="server" Width="350px"></asp:TextBox>
<br />
<asp:Label ID="lblCitySTZip" runat="server" Text="City/ST/Zip:" Font-Size="smaller"></asp:Label>
<br />
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
<asp:TextBox ID="txtState" runat="server" Width="32px" MaxLength="2"></asp:TextBox>
<asp:TextBox ID="txtZip" runat="server"></asp:TextBox>
<br />
<asp:Label ID="lblCountryCode" runat="server" Text="CountryCode:" Font-Size="smaller"></asp:Label>
<br />
<asp:TextBox ID="txtCountryCode" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender
ID="AutoCompleteExtender1"
runat="server" ServicePath=QuadmaxWebService.asmx
ServiceMethod="ZipCode"
MinimumPrefixLength="2"
CompletionSetCount="10"
Enabled="True"
TargetControlID="txtZip"
OnClientItemSelected="getCity()"
>
</cc1:AutoCompleteExtender>
<head runat="server">
<script language="javascript">
function getName()
{
alert("getName");
}
</script>
</head>
<Body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<cc1:TabContainer ID="TabC" runat="server" ActiveTabIndex="0" >
<cc1:TabPanel ID="TP4" runat="server" HeaderText="MISC">
<ContentTemplate>
<asp:Label ID="lblName" Text="Name:" runat="server" Font-Size="Smaller"></asp:Label>
<br />
<asp:TextBox ID="txtFirstName" runat="server" ></asp:TextBox>
<asp:TextBox ID="txtLastName" runat="server" ></asp:TextBox>
<asp:TextBox ID="txtMI" runat="server" Width="32px" MaxLength="1"></asp:TextBox>
<br />
<asp:Label ID="lblAddress" runat="server" Text="Address:" Font-Size="Smaller"></asp:Label>
<br />
<asp:TextBox ID="txtAddress1" runat="server" Width="350px" ></asp:TextBox>
<br />
<asp:TextBox ID="txtAddress2" runat="server" Width="350px"></asp:TextBox>
<br />
<asp:Label ID="lblCitySTZip" runat="server" Text="City/ST/Zip:" Font-Size="Smaller"></asp:Label>
<br />
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
<asp:TextBox ID="txtState" runat="server" Width="32px" MaxLength="2"></asp:TextBox>
<asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>
<br />
<asp:Label ID="lblCountryCode" runat="server" Text="CountryCode:" Font-Size="Smaller"></asp:Label>
<br />
<asp:TextBox ID="txtCountryCode" runat="server"></asp:TextBox>
<br />
<br />
<cc1:AutoCompleteExtender
ID="AutoCompleteMISC"
runat="server"
ServicePath=QuadmaxWebService.asmx
ServiceMethod="ZipCode"
MinimumPrefixLength="2"
Enabled="True"
TargetControlID="txtZipCode"
OnClientItemSelected="getName()" DelimiterCharacters=""
>
</cc1:AutoCompleteExtender>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</form>
</body>
</html>
1) UserControls are .ascx, not .asmx (web service).
2) You should be able to use the Parent property, and follow up the chain until you get to the container that you need. You can combine calls, like this:
Control.Parent.Parent.Pare
Bob