I have recently developed a user control which allows a user to select a person from a datastore of some type (AD in my case). There are two parts to the control. The first part is a asp textbox and an imagebutton. The second part is a panel which allows the user to search by first name, last name, and e-mail to locate a user. Once they have located a user they can click on that user and it will populate the textbox in the first part. I implemented this functionality with the ModalPopupExtender and two UpdatePanels. Initially I thought the user control was working perfectly, that was until I added to a page with a UpdatePanel of it's own. The outside UpdatePanel caused the user control to start doing all kinds of crazy things. I tried everything I could think of to correct this issue for the last two days and I am totally lost on what is causing the problem.
Here is the code
User Control - PeoplePicker.ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PeoplePicker.ascx.vb" Inherits="Controls_PeoplePicker" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<style type="text/css">
.DarkenBackground
{
background-color: rgb(0, 0, 0);
opacity: 0.7; /* Safari, Opera */
-moz-opacity:0.70; /* FireFox */
filter: alpha(opacity=70); /* IE */
z-index: 20;
height: 100%;
width: 100%;
background-repeat:repeat;
position:fixed;
top: 0px;
left: 0px;
}
.ModalPopup
{
background-color: #003e74;
filter: alpha(opacity=100); /* IE */
-moz-opacity: 1.00; /* FireFox */
font-family: Verdana;
border-style: solid;
border-width: 0.75pt;
border-color: White;
}
.ModalPopup h
{
background-color: #003e74;
filter: alpha(opacity=100); /* IE */
-moz-opacity: 1.00; /* FireFox */
font-family: Verdana;
}
.GridViewFixedHeader
{
POSITION: relative;
color: White;
background-color: #646464;
}
.GridScrollBar
{
overflow-y: auto;
height: 200px;
width: 300px;
}
.DefaultCursor
{
cursor: default;
}
.MainPageTable
{
border-collapse: collapse;
padding: 0;
margin: 0
}
.ModalTable
{
height:100%;
width:95%;
margin-left:auto;
margin-right: auto;
}
.ModalTableLabelTD
{
font-size: 8pt;
font-weight: bold;
color: White;
width: 25%
}
.ModalTableControlTD
{
Width: 160px;
}
.GridViewResult
{
background-color: White;
Width: 282px;
padding: 20px;
}
.GridViewResultRows
{
color: Black;
background-color: White;
height: 30px;
}
</style>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler)
function BeginRequestHandler(sender, args)
{
var btn = document.getElementById("<%= btnSearch.ClientID %>");
btn.disabled = true;
}
function EndRequestHandler(sender, args)
{
var btn = document.getElementById("<%= btnSearch.ClientID %>");
btn.disabled = false;
}
</script>
<table class="MainPageTable">
<tr>
<td>
<asp:UpdatePanel runat="server" ID="upPerson">
<ContentTemplate>
<asp:TextBox runat="server" ID="txtPerson" ReadOnly="true"></asp:TextBox>
<asp:TextBox runat="server" ID="txtGUID" ReadOnly="true" Visible="false"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td valign="bottom">
<asp:ImageButton runat="server" ID="btnPeoplePicker" ImageUrl="~/Images/Person.jpg" />
<input id="dummy" type="button" style="display: none" runat="server" />
</td>
</tr>
</table>
<cc1:modalpopupextender
runat="server"
id="mpeThePopup"
TargetControlID="dummy"
PopupDragHandleControlID="PickerHeader"
PopupControlID="pnlModalPopUpPanel"
CancelControlID="btnClose"
BackgroundCssClass="DarkenBackground"
DropShadow="true">
</cc1:modalpopupextender>
<!-- Must have style="display:none" in the panel to prevent a flashing bug from happening with the
ModalPopupExtender style="display:none"-->
<asp:Panel runat="server" ID="pnlModalPopUpPanel" CssClass="ModalPopup" Width="500px" >
<div style="text-align:right; padding:10px; cursor: move" id="PickerHeader">
<asp:ImageButton runat="server" ID="btnClose" ImageUrl="~/Images/close.png" CssClass="DefaultCursor" Height="100%" />
</div>
<asp:UpdatePanel ID="udpInnerUpdatePanel" runat="Server" UpdateMode="Conditional">
<ContentTemplate>
<table class="ModalTable" cellspacing="10">
<tr>
<td style="font-size: 13pt; font-weight:900; color: White;" colspan="2">
People Picker
</td>
</tr>
<tr style="height:18px;">
<td colspan="2"><hr style="color:White; height: 1px;" /></td>
</tr>
<tr>
<td class="ModalTableLabelTD">
First Name:
</td>
<td>
<asp:TextBox runat="server" ID="txtFirstName" CssClass="ModalTableControlTD"></asp:TextBox>
</td>
</tr>
<tr>
<td class="ModalTableLabelTD">
Last Name:
</td>
<td>
<asp:TextBox runat="server" ID="txtLastName" CssClass="ModalTableControlTD"></asp:TextBox>
</td>
</tr>
<tr>
<td class="ModalTableLabelTD">
E-Mail:
</td>
<td>
<asp:TextBox runat="server" ID="txtEmail" CssClass="ModalTableControlTD"></asp:TextBox>
</td>
</tr>
<tr>
<td class="ModalTableLabelTD" valign="top">
Results:
</td>
<td>
<div id="dHorizontalScroll" runat="server" class="GridScrollBar">
<asp:GridView runat="server" ID="gvUserInfo" DataKeyNames="objectGUID" CssClass="GridViewResult" AutoGenerateColumns="false" GridLines="None"
CellPadding="1" AutoGenerateSelectButton="false" EmptyDataText="No results">
<Columns>
<asp:ButtonField ButtonType="Image" ItemStyle-Width="15%" ImageUrl="~/Images/AddPerson.jpg" CommandName="Select" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderStyle-HorizontalAlign="left" DataField="displayName" HeaderText="Name" />
</Columns>
<RowStyle CssClass="GridViewResultRows" />
<HeaderStyle CssClass="GridViewFixedHeader" />
</asp:GridView>
</div>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<div style="text-align: center; padding: 8px; width: 100%">
<asp:button runat="server" id="btnSearch" Text="Search" Width="85px" Height="25px" />
</div>
<asp:UpdateProgress ID="upPickerStatus" runat="server">
<ProgressTemplate>
<div style="vertical-align: middle; margin-left: auto; margin-right: auto; padding: 10px; color: White; width: 100%; text-align: center">
<img src="Images/ajax-loader.gif" alt="" id="iUpdating" /> SEARCHING...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Panel>
User Control - PeoplePicker.ascx.vb
Imports ADWebService.ADLookup
Imports System.Data
Partial Class Controls_PeoplePicker
Inherits System.Web.UI.UserControl
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim search As New ADWebService.ADLookup
Dim results As New ADWebService.EmailAddressData
' Call the AD web service to search for a user
results = search.ADSearch(Me.txtLastName.Text, Me.txtFirstName.Text, Me.txtEmail.Text)
Me.gvUserInfo.DataSource = FormatUserInfo(results.dsData)
Me.gvUserInfo.DataBind()
Me.mpeThePopup.Show()
End Sub
Protected Sub btnPeoplePicker_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnPeoplePicker.Click
Me.txtFirstName.Text = String.Empty
Me.txtLastName.Text = String.Empty
Me.txtEmail.Text = String.Empty
Me.gvUserInfo.DataSource = Nothing
Me.gvUserInfo.DataBind()
If Not txtPerson.Text = String.Empty Then
If Not IsNothing(Me.txtPerson.Text.IndexOf(",")) AndAlso Not Me.txtPerson.Text.IndexOf(",") = -1 Then
Dim FirstName As String
FirstName = Me.txtPerson.Text.Substring(Me.txtPerson.Text.IndexOf(",") + 1).Trim
Me.txtFirstName.Text = FirstName.Substring(0, FirstName.IndexOf(" "))
Me.txtLastName.Text = Me.txtPerson.Text.Substring(0, Me.txtPerson.Text.IndexOf(",")).Trim
End If
End If
Me.mpeThePopup.Show()
End Sub
Protected Sub gvUserInfo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvUserInfo.SelectedIndexChanged
' Get the value from the GridView and populate the textbox on the parent form
Me.txtPerson.Text = Server.HtmlDecode(gvUserInfo.SelectedRow.Cells(1).Text)
Me.txtGUID.Text = Me.gvUserInfo.DataKeys(Me.gvUserInfo.SelectedRow.RowIndex).Value
Me.mpeThePopup.Hide()
End Sub
' This function allows you to format the result set. The only thing I have chosen to
' do is remove the rows which do not have e-mails.
Private Function FormatUserInfo(ByVal userInfo As Data.DataSet) As Data.DataTable
Dim table As DataTable
Dim selectExpression As String
Dim rowsToRemove() As DataRow
table = userInfo.Tables("UserInformation")
' Select all rows that do not have an e-mail address
selectExpression = "mail = ''"
rowsToRemove = table.Select(selectExpression)
For Each row As DataRow In rowsToRemove
table.Rows.Remove(row)
Next
Return table
End Function
Public Property UserGUID() As String
Get
Return Me.txtGUID.Text
End Get
Set(ByVal value As String)
Me.txtGUID.Text = value
End Set
End Property
Public Property Text() As String
Get
Return Me.txtPerson.Text
End Get
Set(ByVal value As String)
Me.txtPerson.Text = value
End Set
End Property
End Class
Page the control is being used on that is causing the problems
<%@ Page Title="" Language="VB" MasterPageFile="~/Main.master" ValidateRequest="false" AutoEventWireup="false" CodeFile="DepartmentAdmin.aspx.vb" EnableEventValidation="false" Inherits="DepartmentAdmin" %>
<%@ Register src="Controls/PeoplePicker.ascx" tagname="PeoplePicker" tagprefix="uc1" %>
<asp:Content ID="cDpartmentAdmin" ContentPlaceHolderID="form" runat="Server">
<table width="90%" border="0" style="margin-left: auto; margin-right: auto" cellpadding="0" cellspacing="0">
<tr>
<!-- Changing the layout of these TDs will result in the rounded corners getting out of alignment -->
<td style="width: 16px"><img src="images/top_lef.gif" alt="" width="16px" height="16px" /></td>
<td style="background: url(images/top_mid.gif); height: 16px"><img src="images/top_mid.gif" width="16px" height="16px" alt="" /></td>
<td style="width: 24px"><img src="images/top_rig.gif" alt="" width="24px" height="16px" /></td>
</tr>
<tr>
<td style="background: url(images/cen_lef.gif); width: 16px">
<img src="images/cen_lef.gif" alt="" width="16px" height="11px" />
</td>
<td style="background-color: #F7F8FB">
<asp:UpdatePanel ID="upDepartmentAdministration" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<table class="MainContentTable" cellpadding="0" cellspacing="10" border="0">
<tr align="left">
<td colspan="2">
<label class="MainContentTableHeader">
Department Administration</label>
</td>
<td align="right">
<asp:Label runat="server" ID="lblStatus" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr style="height: 20px">
<td colspan="3">
<hr />
</td>
</tr>
<tr>
<td class="FirstColumnRequiredLabel">
Action:
</td>
<td class="SpanColumnsControl" colspan="2">
<asp:DropDownList runat="server" ID="ddlDepartmentAction" AutoPostBack="true">
<asp:ListItem Value="-1" Selected="True">Select One</asp:ListItem>
<asp:ListItem Value="1">New Department</asp:ListItem>
<asp:ListItem Value="2">Edit Department</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
<table runat="server" id="tDepartmentAction" visible="false" border="0" class="MainContentTable" cellpadding="0" cellspacing="10">
<tr>
<td class="FirstColumnRequiredLabel">
Department:
</td>
<td class="SecondColumnControl">
<asp:TextBox runat="server" ID="txtDepartment" Visible="false" Width="75%"></asp:TextBox>
<asp:DropDownList runat="server" ID="ddlDepartment" Visible="false"
AutoPostBack="true"></asp:DropDownList>
</td>
<td class="ThirdColumnRequiredLabel">
Manager:
</td>
<td class="FourthColumnControl">
<uc1:PeoplePicker runat="server" ID="ppManager" />
</td>
</tr>
<tr>
<td class="FirstColumnRequiredLabel">
Value Center:
</td>
<td class="SecondColumnControl">
<asp:DropDownList runat="server" AutoPostBack="true" ID="ddlValueCenter" DataTextField="Text" DataValueField="Value"></asp:DropDownList>
</td>
<td class="ThirdColumnRequiredLabel">
Administrator:
</td>
<td class="FourthColumnControl">
<uc1:PeoplePicker runat="server" ID="ppAdministrator" />
</td>
</tr>
<tr>
<td class="FirstColumnRequiredLabel">
Description:
</td>
<td class="SpanColumnsControl" colspan="3">
<asp:TextBox runat="server" ID="txtDescription" TextMode="MultiLine" Width="75%" Rows="4"></asp:TextBox>
</td>
</tr>
<tr style="height: 15px">
<td colspan="3"></td>
</tr>
<tr align="center">
<td colspan="4">
<asp:Button runat="server" ID="btnClearForm" Text="Clear Form" CssClass="StandardButton" />
<asp:Button runat="server" ID="btnSubmit" Text="Submit" CssClass="StandardButton" />
</td>
</tr>
<tr>
<td colspan="4">
<b>All bolded fields are required</b>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlDepartmentAction" />
<asp:AsyncPostBackTrigger ControlID="ddlDepartment" />
</Triggers>
</asp:UpdatePanel>
</td>
<td style="background: url(images/cen_rig.gif); width: 24px">
<img src="images/cen_rig.gif" alt="" width="24px" height="11px" />
</td>
</tr>
<tr>
<td style="width: 16px; height: 16px"><img src="images/bot_lef.gif" alt="" width="16px" height="16px" /></td>
<td style="background: url(images/bot_mid.gif); height: 16px"><img src="images/bot_mid.gif" alt="" width="16px" height="16px" /></td>
<td style="width: 24px; height: 16px"><img src="images/bot_rig.gif" alt="" width="24px" height="16px" /></td>
</tr>
</table>
</asp:Content>
I have tried everything I can think of. Any help that the ASP.NET community can provide would be GREATLY appreciated.