Hi everyone,
1st of all sorry for asking this, actually I manage to to child pass to parent thingy, but this time I got a problem when I need to enhance my form. Let say I need to get a Customer Name & Detail Address from a Child form, it work when I just need to return a normal value such as name or number but not for Address, the value for Address such like this :
Level 12, Menara Rainbow, Jalan Yellow, Taman Rainbow, 80400 Johor Bahru, Johor Darul Takzim. 02-10101010 / 01-11111111
* User keep the address together with the phone number
My parent form for this value is asp:TextBox with TextMode="MultiLine" Rows="4" while the data will be coming from child gridview
HTML:
<asp:TextBox ID="txtCustomerContact" runat="server" Text="Use search button only" Tooltip="Use search button only" TextMode="MultiLine" Rows="4" />
From Parent form
As I'm clicking this search icon with this parameter :
HTML:
<img alt="Search customer information" id="imgCustomer" src="/_layouts/images/search.png" border="0" onclick="var win=window.open('/_layouts/project/SearchCustomer.aspx','SearchCustomer','width=1000,height=600,scrollbars=1'); win.moveTo(screen.width/2-500,screen.height/2-300)" onmouseover="this.style.cursor='hand'" />
BTW, I got this JavaScript to do this :
HTML:
<script type="text/javascript">
function PopulateCustomerInfo(Address) {
document.getElementById('<%= txtCustomerContact.ClientID %>').value = Address;
**
</script>
*** I just focus on this Adress issue only & take out the rest of code
From Child form
I need to search the specific Customer Name 1st in order to retrieve the information from it's gridview.
This is my gridview :
HTML:
<asp:gridview runat="server" ID="gvSearchCustomer" OnPageIndexChanging="gvSearchCustomer_PageIndexChanging"
AutoGenerateColumns="False" EmptyDataText="No information available!" AllowPaging="True" CssClass="gvGridView"
AutoGenerateSelectButton="True" OnRowDataBound="gvSearchResult_RowDataBound"
onselectedindexchanged="gvSearchCustomer_SelectedIndexChanged" CellPadding="5">
<columns>
<asp:TemplateField HeaderText="Address" ShowHeader="true" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="true">
<ItemTemplate>
<asp:Label ID="lblAddress" runat="server" Text='<%# Bind("Address") %>' Width="120px" />
</ItemTemplate>
<HeaderStyle Font-Bold="True" HorizontalAlign="Left" Width="150px" />
</asp:TemplateField>
</columns>
<HeaderStyle CssClass="gvGridViewHeader" />
<FooterStyle ForeColor="Black" BackColor="#C6C3C6" />
<SelectedRowStyle ForeColor="White" Font-Bold="True" BackColor="#9471DE" />
<RowStyle CssClass="ms-vb2" />
<AlternatingRowStyle CssClass="ms-vb2 ms-alternating" />
</asp:gridview>
As for the script to return the selected value is :
HTML:
<script type="text/javascript">
function callWindow(Address) {
window.opener.PopulateCustomerInfo(Address);
window.close();
**
function highlightRow(obj) {
obj.style.cursor = 'hand';
obj.originalcolor = obj.style.backgroundColor;
obj.style.backgroundColor = 'yellow';
**
function resetHighlight(obj) {
obj.style.backgroundColor = obj.originalcolor;
**
</script>
And this is the code behind which I use to select the specific row :
Code:
public void gvSearchResult_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "highlightRow(this)");
e.Row.Attributes.Add("onmouseout", "resetHighlight(this)");
string Parent = @"callWindow('" +
((Label)e.Row.FindControl("lblAddress")).Text.Replace("'", "\\'") + "')";
e.Row.Attributes.Add("onclick", Parent);
**
**
My question is :
Why it's not working? All this while it's been working fine if I use the code to get the Name, Date, Currency or Number but not for this one.