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 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
UPDATE : After doing some checking myself, I findout those value from Address cannot be pass to Parent form due to char ' and the text is "multiline" value, however those Address which is "singleline" value and contain char & or - or , or ( or ) won't have
any issue.
How do I fix this?
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("^(?=.*[0-9]+.*)[0-9a-zA-Z]{8,15}$", "^(?=.*[0-9]+.*)[0-9a-zA-Z]{8,15}$") + "')"; //This part giving me headache
e.Row.Attributes.Add("onclick", Parent);
}
}
Try Removing Char ' and than replacing all other symbols u need to replace,
but first remove this char ' from your string
Just a suggestion
Beware of bugs in the above code; I have only proved it correct, not tried it.
-------------------------------------------------------
Contact-Info:Adils.kiet@gmail.com
mutanic
Member
19 Points
16 Posts
RegEx issue : Value with char (',/-) cannot pass from Child to Parent
Dec 31, 2012 04:10 AM|LINK
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 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
From Parent form
As I'm clicking this search icon with this parameter :
<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 :
<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 :
<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 :
<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 :
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.
mutanic
Member
19 Points
16 Posts
Re: RegEx issue : Value with char (',/-) cannot pass from Child to Parent
Dec 31, 2012 06:45 AM|LINK
After thinking for a while, could it be an RegEx issue? How do I overcome this?
mutanic
Member
19 Points
16 Posts
Re: RegEx issue : Value with char (',/-) cannot pass from Child to Parent
Dec 31, 2012 08:30 AM|LINK
Confirm!
UPDATE : After doing some checking myself, I findout those value from Address cannot be pass to Parent form due to char ' and the text is "multiline" value, however those Address which is "singleline" value and contain char & or - or , or ( or ) won't have any issue.
How do I fix this?
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("^(?=.*[0-9]+.*)[0-9a-zA-Z]{8,15}$", "^(?=.*[0-9]+.*)[0-9a-zA-Z]{8,15}$") + "')"; //This part giving me headache e.Row.Attributes.Add("onclick", Parent); } }I use this
^(?=.*\d)(?=.*[a-zA-Z]).{8,15}$
molly_c
Participant
1590 Points
401 Posts
Re: RegEx issue : Value with char (',/-) cannot pass from Child to Parent
Jan 07, 2013 04:13 AM|LINK
This pattern solve your problem?
Molly
It's time to start living the life you are imagined.
Jugg3rNaut
Member
474 Points
109 Posts
Re: RegEx issue : Value with char (',/-) cannot pass from Child to Parent
Jan 07, 2013 06:08 AM|LINK
Try Removing Char ' and than replacing all other symbols u need to replace,
but first remove this char ' from your string
Just a suggestion
-------------------------------------------------------
Contact-Info:Adils.kiet@gmail.com