Click to See Complete Forum and Search --> : [RESOLVED] Modal popup extender value to textbox


jenbuh
06-29-2009, 11:38 AM
Hi,

I've got a page that allows users to lookup employees. Basically a modal popup extender pops up when a button is clicked and the user enters in the name they want. When they select the employee out of the gridview I want their name and email address to be populated into the textboxes on the form.

The textboxes and modal extender are in my EmployeeLookup.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EmployeeLookup.ascx.cs" Inherits="EmployeeFind" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<link href="Styles/ws_style.css" rel="stylesheet" type="text/css" />

<div class="formRow">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="Label1" runat="server" Text="*Requestor: " height="16px"
width="140px" style="text-align:right"></asp:Label>
<asp:TextBox ID="txtRequestorName" runat="server" Width="259px"></asp:TextBox>
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server"
ControlToValidate="txtrequestorname" Display="Dynamic"
ErrorMessage="Required: Reqestor Name">*</asp:RequiredFieldValidator>
&nbsp;&nbsp;<img alt="Required: Your name" src="Images/question.jpg"
style="width: 20px" /><i><asp:ImageButton ID="ibLookup0"
runat="server" ImageURL="~/images/lookup.gif" width="21" Height="19"
CausesValidation="false" />
Employee ID Look-up</i>

&nbsp;</div>
<div class="formRow">
<asp:Label ID="Label2" runat="server" Text="*E-mail: " height="16px"
width="140px" style="text-align:right"></asp:Label>
<asp:TextBox ID="RequestorEmail" runat="server" width="259px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="RequestorEmail" Display="Dynamic"
ErrorMessage="Required: Requestor E-mail">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="RequestorEmail" Display="Dynamic"
ErrorMessage="Invalid Requestor E-mail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
&nbsp;<img alt="Required: Your e-mail" src="Images/question.jpg" style="width: 20px" /><br />
</div>
<div class="formRow">
<asp:Label ID="Label3" runat="server" height="16px" style="text-align:right"
Text="*Approver: " width="140px"></asp:Label>
<asp:TextBox ID="txtApproverName" runat="server" width="259px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtApproverName" Display="Dynamic"
ErrorMessage="Required: Approver Name">*</asp:RequiredFieldValidator>
&nbsp;
<img alt="Required: Cost Center Manager or Designee Approval"
src="Images/question.jpg" style="width: 20px" /><asp:ImageButton ID="ibLookup"
runat="server" ImageURL="~/images/lookup.gif"
width="21" Height="19"
CausesValidation="false" />
</div>
<div class="formRow">
<asp:Label ID="Label4" runat="server" Text="*Approver E-mail: " height="16px"
width="140px" style="text-align:right"></asp:Label>
<asp:TextBox ID="ApproverEmail" runat="server" width="259px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="ApproverEmail" Display="Dynamic"
ErrorMessage="Required: Approver E-mail">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="ApproverEmail" Display="Dynamic"
ErrorMessage="Invalid Approver E-mail"

ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
&nbsp;<img src="Images/question.jpg" style="width: 20px"
alt="Required: Above approver e-mail" /><br />

</div>


<asp:Panel ID="pnlSearch" runat="Server" BorderColor="cornsilk" >
<fieldset style="padding: 2px 2p; background-color:#E0E0E0 ; Width: 600px; left: 0px; top: 7px;" >
<asp:Panel ID="pnlEmployees" runat="server" Visible="true" Width="540px" >
<font style="font-size: 9pt; font-family: Arial;">Enter the First Name and/or
Last Name to search. Click the employee you would like to select:</font>
<br />
<asp:TextBox ID="txtName" runat="server" Width="200px" Font-Size="X-Small" ></asp:TextBox>
<asp:LinkButton ID="lbSearch" runat="server" Text="[Search]" Font-Overline="False" Font-Underline="False" Font-Size="X-Small" OnClick="lbSearch_Click" ValidationGroup="lookup" ></asp:LinkButton>
<asp:LinkButton ID="lbClose" runat="server" Text="[Close]" Font-Overline="False" Font-Underline="False" Font-Size="X-Small" CausesValidation="false" ></asp:LinkButton>
<br />
<asp:RequiredFieldValidator ID="reqName" runat="Server" ControlToValidate="txtName" Display="Dynamic" ErrorMessage="*required field" Font-Size="X-Small" ValidationGroup="lookup" EnableClientScript="false"></asp:RequiredFieldValidator>
<br />
<asp:Panel ID="pnDisplay" BackColor="white" BorderColor="cornsilk" BorderStyle="Outset" BorderWidth="1" runat="Server" ScrollBars="Vertical" Height="107px" Width="100%" >
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:UpdateProgress ID="updateProcess1" runat="server" >
<ProgressTemplate>
<asp:Image ID="LoadingImage2" runat="server" ImageUrl="~/images/animated_loading.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:GridView ID = "gvResult" runat="server" CellSpacing="1"
AlternatingRowStyle-BackColor="cornsilk" CellPadding="1"
Font-Size="X-Small" GridLines="Horizontal"
BackColor="White" SelectedRowStyle-BackColor="#99ccff" Width="518px"
OnRowCreated="gvResult_RowCreated" OnRowDataBound="gvResult_RowDataBound"
OnSelectedIndexChanged="gvResult_SelectedIndexChanged"
OnRowCommand="gvResult_RowCommand" >
<Columns>
<asp:CommandField ButtonType="Link" ItemStyle-CssClass="HideButton"
SelectText="Select" ShowSelectButton="true"
HeaderStyle-CssClass ="HideButton" >
<HeaderStyle CssClass="HideButton" />
<ItemStyle CssClass="HideButton" />
</asp:CommandField>
</Columns>
<SelectedRowStyle BackColor="#99CCFF" />
<AlternatingRowStyle BackColor="Cornsilk" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</asp:Panel>
</fieldset>
</asp:Panel>

<ajaxToolkit:ModalPopupExtender ID="mpeSearch" runat="Server" PopupControlID="pnlSearch"
TargetControlID="ibLookup" BackgroundCssClass="modalBackground" Y="50" X="50"
EnableViewState="false" >
</ajaxToolkit:ModalPopupExtender>



And after my gridview populates by code i'd rather not put on here, I have this code under the SelectedIndexChanged event:


this.txtRequestorName.Text = SecurityFunctions.CheckProperty("gvResult.SelectedRow.Cells[2]", gvResult.Rows[gvResult.SelectedIndex].Cells[2].Text, @"^[a-zA-Z\s.\-,._']+$", 100);
mpeSearch.Hide();


When I debug it and stop it at this line, it tells me that the correct values are placed in the text property from the cells.text property however, after the popup closes there is nothing in the textboxes.

Any ideas?

jenbuh
07-01-2009, 12:19 PM
Figured out the problem...the text boxes that I was trying to get information into from the mpe needed to be inside the update panel.

Simple things always trip me up.