User Control with popup used more than once per page does not work

L

lds

Our ASP.NET application has a page that we enter addresses for
clients. A client can have more than one address in this
application. We also have other pages that we enter addresses such as
Contacts etc so we created a user control for entering an address. on
the aspx page we have the user control to enter a new address and we
have a list of existing addresses. If the user selects a link, the
existing address which is view only switches to the user control so
that it can be edited. Now there would be two instances of the same
control on the page.

Because our list of city/town is extremely long we have created a
search page. When the user enters some criteria and selects search a
popup window appears with a list of city/towns that match the string
entered. The user can select one location and click a button to close
the popup. The city/town that is selected is put in a read-only text
box on the user control

This works like a charm when we are entering a new address, but does
not when we are editing an existing address.

Just wondering if there is an alternate way to do this so that we can
distinguish between the controls and return the value to the right
textboxes.

Please let me know if you think this would have been better in another
newsgroup...java or javascript maybe...

Thanks.

Here is the javascript code that opens the popup and returns the
values to the contols. Please let me know if you would like me to
send you all of the code for the aspx, ascx and aspx for the popup
page.

<script language="javascript">

window.onerror = JSError;

// Global variables
var txtPlaceNameSearch;
var txtPlaceName;
var txtPlaceNameCD

//FUNCTION: SetupForm
// PURPOSE: This sets the values of the global variable

function SetupForm(strPlaceNameSearch, strPlaceName, strPlaceNameCD)
{
txtPlaceNameSearch = document.getElementById(strPlaceNameSearch);
txtPlaceName = document.getElementById(strPlaceName);
txtPlaceNameCD = document.getElementById(strPlaceNameCD);
}



//FUNCTION: GetPlaceName
// PURPOSE: Displays a modal dialog box that allows a user to select
// a placename.

function GetPlaceName()
{
// Determine the current selected application code

var strPlaceNameSearch = txtPlaceNameSearch.value;

var pageURL = '<%=Session("ApplicationPath")%>/WebUserControls/
PlaceName/PlaceNamePopup.aspx?place_name_search=' +
strPlaceNameSearch;
var windowOptions = 'dialogHeight: 463px; dialogWidth: 483px;
center: yes; help: no; resizable: no; status: no;';

// Show the modal dialog window and recieve the return value
// The showModalDialog method only works in IE
var returnValue = window.showModalDialog(pageURL, null,
windowOptions);

// If the return value is not null then set our exam version ID and
// exam version name text boxes to the appropriate values found in
// the return value array.

if(returnValue != null)
{
txtPlaceName.value = returnValue[0];
txtPlaceNameSearch.Value = returnValue[1];
txtPlaceNameCD.value = returnValue[2];
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top