Is there a way to use Regex inside of a tag, such as asp:label?
I tried something like this but can't make it work:
<asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone")
%>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/>
I have this inside my Repeater and want it to filter the field during bind.
I can do it afterwards by just looping through the repeater items, but that
is extra work and time.
Thanks,
Tom 6 1755
try wrapping it around the Container.DataItem("Phone") section, rather than
the text section
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
"tshad" <tf*@dslextreme.com> wrote in message
news:ep**************@tk2msftngp13.phx.gbl... Is there a way to use Regex inside of a tag, such as asp:label?
I tried something like this but can't make it work:
<asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone") %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/>
I have this inside my Repeater and want it to filter the field during bind. I can do it afterwards by just looping through the repeater items, but that is extra work and time.
Thanks,
Tom
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl... try wrapping it around the Container.DataItem("Phone") section, rather than the text section
I thought that was what I was doing? Did I miss something?
Tom
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
"tshad" <tf*@dslextreme.com> wrote in message news:ep**************@tk2msftngp13.phx.gbl... Is there a way to use Regex inside of a tag, such as asp:label?
I tried something like this but can't make it work:
<asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone") %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/>
I have this inside my Repeater and want it to filter the field during bind. I can do it afterwards by just looping through the repeater items, but that is extra work and time.
Thanks,
Tom
meaning
<asp:label id="Phone" text='<%# Regex.Replace(Container.DataItem("Phone")
,"(\d{3})(\d{3})(\d{4})","($1) $2-$3") %>' runat="server"/>
Sreejith
"tshad" wrote: "John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... try wrapping it around the Container.DataItem("Phone") section, rather than the text section
I thought that was what I was doing? Did I miss something?
Tom
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
"tshad" <tf*@dslextreme.com> wrote in message news:ep**************@tk2msftngp13.phx.gbl... Is there a way to use Regex inside of a tag, such as asp:label?
I tried something like this but can't make it work:
<asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone") %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/>
I have this inside my Repeater and want it to filter the field during bind. I can do it afterwards by just looping through the repeater items, but that is extra work and time.
Thanks,
Tom
"Sreejith Ram" <Sr*********@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com... meaning
<asp:label id="Phone" text='<%# Regex.Replace(Container.DataItem("Phone") ,"(\d{3})(\d{3})(\d{4})","($1) $2-$3") %>' runat="server"/>
That worked great.
Here is what I was doing it. I first get the data in my Repeater:
<asp:label ID="Wages" text='<%#
Regex.Replace(Container.DataItem("Wages"),"\-|\,",""),"(\d{3})(\d{3})(\d{4})
","($1) $2-$3" %>' runat="server"/>
Then I go through the RepeaterItem list and filter the phone numbers.
for each oItem as RepeaterItem in ExperienceRepeater.items
oLabel = Ctype(oItem.FindControl("Phone"),Label)
oLabel.Text = Regex.Replace(Regex.Replace(oLabel.Text,"\-|\
",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")
next
If I replace the Regex line into the Repeater, as you show:
<asp:label ID="Wages" text='<%#
Regex.Replace(Regex.Replace(Container.DataItem("Ph one"),"\-|\
",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3" %>' runat="server"/>
It works fine.
What about a BoundColumn?
I tried changing my Bound Column:
<asp:BoundColumn DataField=ContactPhone
HeaderText="Phone"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign="Top"
SortExpression="ContactPhone">
and replaced it with:
<asp:BoundColumn DataField='Regex.Replace(Regex.Replace(ContactPhon e,"\-|\
",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")'
HeaderText="Phone"
ReadOnly="true"
Visible="true"
ItemStyle-VerticalAlign="Top"
SortExpression="ContactPhone">
but got the error:
A field or property with the name
'Regex.Replace(Regex.Replace(ContactPhone,"\-|\
",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' was not found on the selected
datasource.
Do I have to use a TemplateColumn and use an asp:Label?
Thanks,
Tom
Sreejith
"tshad" wrote:
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... try wrapping it around the Container.DataItem("Phone") section, rather than the text section
I thought that was what I was doing? Did I miss something?
Tom
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
"tshad" <tf*@dslextreme.com> wrote in message news:ep**************@tk2msftngp13.phx.gbl... > Is there a way to use Regex inside of a tag, such as asp:label? > > I tried something like this but can't make it work: > > <asp:label id="Phone" text=Regex.Replace('<%#
Container.DataItem("Phone")> %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/> > > I have this inside my Repeater and want it to filter the field during > bind. > I can do it afterwards by just looping through the repeater items,
but> that > is extra work and time. > > Thanks, > > Tom > >
<asp:BoundColumn DataField='Regex.Replace(Regex.Replace(ContactPhon e,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' HeaderText="Phone" ReadOnly="true" Visible="true" ItemStyle-VerticalAlign="Top" SortExpression="ContactPhone">
Above wouldnt work.. wrong usage..
I believe, you will be able to create a TemplateColumn as below
<asp:TemplateColumn>
<ItemTemplate>
<asp:label id="Phone" text='<%#
Regex.Replace(Container.DataItem("Phone")
,"(\d{3})(\d{3})(\d{4})","($1) $2-$3") %>' runat="server"/>
</ItemTemplate>
<asp:TemplateColumn>
Sreejith
"tshad" wrote:
"Sreejith Ram" <Sr*********@discussions.microsoft.com> wrote in message news:96**********************************@microsof t.com... meaning
<asp:label id="Phone" text='<%# Regex.Replace(Container.DataItem("Phone") ,"(\d{3})(\d{3})(\d{4})","($1) $2-$3") %>' runat="server"/>
That worked great.
Here is what I was doing it. I first get the data in my Repeater:
<asp:label ID="Wages" text='<%# Regex.Replace(Container.DataItem("Wages"),"\-|\,",""),"(\d{3})(\d{3})(\d{4}) ","($1) $2-$3" %>' runat="server"/>
Then I go through the RepeaterItem list and filter the phone numbers.
for each oItem as RepeaterItem in ExperienceRepeater.items oLabel = Ctype(oItem.FindControl("Phone"),Label) oLabel.Text = Regex.Replace(Regex.Replace(oLabel.Text,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3") next
If I replace the Regex line into the Repeater, as you show:
<asp:label ID="Wages" text='<%# Regex.Replace(Regex.Replace(Container.DataItem("Ph one"),"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3" %>' runat="server"/>
It works fine.
What about a BoundColumn?
I tried changing my Bound Column:
<asp:BoundColumn DataField=ContactPhone HeaderText="Phone" ReadOnly="true" Visible="true" ItemStyle-VerticalAlign="Top" SortExpression="ContactPhone">
and replaced it with:
<asp:BoundColumn DataField='Regex.Replace(Regex.Replace(ContactPhon e,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' HeaderText="Phone" ReadOnly="true" Visible="true" ItemStyle-VerticalAlign="Top" SortExpression="ContactPhone">
but got the error:
A field or property with the name 'Regex.Replace(Regex.Replace(ContactPhone,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' was not found on the selected datasource.
Do I have to use a TemplateColumn and use an asp:Label?
Thanks,
Tom
Sreejith
"tshad" wrote:
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... > try wrapping it around the Container.DataItem("Phone") section, rather > than the text section
I thought that was what I was doing? Did I miss something?
Tom > > > -- > Regards > > John Timney > ASP.NET MVP > Microsoft Regional Director > > "tshad" <tf*@dslextreme.com> wrote in message > news:ep**************@tk2msftngp13.phx.gbl... >> Is there a way to use Regex inside of a tag, such as asp:label? >> >> I tried something like this but can't make it work: >> >> <asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone") >> %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/> >> >> I have this inside my Repeater and want it to filter the field during >> bind. >> I can do it afterwards by just looping through the repeater items, but >> that >> is extra work and time. >> >> Thanks, >> >> Tom >> >> > >
"Sreejith Ram" <Sr*********@discussions.microsoft.com> wrote in message
news:58**********************************@microsof t.com... <asp:BoundColumn DataField='Regex.Replace(Regex.Replace(ContactPhon e,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' HeaderText="Phone" ReadOnly="true" Visible="true" ItemStyle-VerticalAlign="Top" SortExpression="ContactPhone"> Above wouldnt work.. wrong usage.. I believe, you will be able to create a TemplateColumn as below
You're right.
That seems to be the case. I found that since I have been leaning more
towards formatting on the client side, that I making more use of the
templateColumn and less of the BoundColumn.
Thanks,
Tom <asp:TemplateColumn>
<ItemTemplate> <asp:label id="Phone" text='<%# Regex.Replace(Container.DataItem("Phone") ,"(\d{3})(\d{3})(\d{4})","($1) $2-$3") %>' runat="server"/> </ItemTemplate>
<asp:TemplateColumn>
Sreejith
"tshad" wrote:
"Sreejith Ram" <Sr*********@discussions.microsoft.com> wrote in message news:96**********************************@microsof t.com... > > meaning > > <asp:label id="Phone" text='<%# > Regex.Replace(Container.DataItem("Phone") > ,"(\d{3})(\d{3})(\d{4})","($1) $2-$3") %>' runat="server"/> >
That worked great.
Here is what I was doing it. I first get the data in my Repeater:
<asp:label ID="Wages" text='<%# Regex.Replace(Container.DataItem("Wages"),"\-|\,",""),"(\d{3})(\d{3})(\d{4}) ","($1) $2-$3" %>' runat="server"/>
Then I go through the RepeaterItem list and filter the phone numbers.
for each oItem as RepeaterItem in ExperienceRepeater.items oLabel = Ctype(oItem.FindControl("Phone"),Label) oLabel.Text = Regex.Replace(Regex.Replace(oLabel.Text,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3") next
If I replace the Regex line into the Repeater, as you show:
<asp:label ID="Wages" text='<%# Regex.Replace(Regex.Replace(Container.DataItem("Ph one"),"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3" %>' runat="server"/>
It works fine.
What about a BoundColumn?
I tried changing my Bound Column:
<asp:BoundColumn DataField=ContactPhone HeaderText="Phone" ReadOnly="true" Visible="true" ItemStyle-VerticalAlign="Top" SortExpression="ContactPhone">
and replaced it with:
<asp:BoundColumn DataField='Regex.Replace(Regex.Replace(ContactPhon e,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' HeaderText="Phone" ReadOnly="true" Visible="true" ItemStyle-VerticalAlign="Top" SortExpression="ContactPhone">
but got the error:
A field or property with the name 'Regex.Replace(Regex.Replace(ContactPhone,"\-|\ ",""),"(\d{3})(\d{3})(\d{4})","($1) $2-$3")' was not found on the selected datasource.
Do I have to use a TemplateColumn and use an asp:Label?
Thanks,
Tom
> Sreejith > > "tshad" wrote: > > > > > "John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message > > news:%2****************@TK2MSFTNGP15.phx.gbl... > > > try wrapping it around the Container.DataItem("Phone") section, > > > rather > > > than the text section > > > > I thought that was what I was doing? Did I miss something? > > > > Tom > > > > > > > > > -- > > > Regards > > > > > > John Timney > > > ASP.NET MVP > > > Microsoft Regional Director > > > > > > "tshad" <tf*@dslextreme.com> wrote in message > > > news:ep**************@tk2msftngp13.phx.gbl... > > >> Is there a way to use Regex inside of a tag, such as asp:label? > > >> > > >> I tried something like this but can't make it work: > > >> > > >> <asp:label id="Phone" text=Regex.Replace('<%# Container.DataItem("Phone") > > >> %>',"(\d{3})(\d{3})(\d{4})","($1) $2-$3") runat="server"/> > > >> > > >> I have this inside my Repeater and want it to filter the field > > >> during > > >> bind. > > >> I can do it afterwards by just looping through the repeater items, but > > >> that > > >> is extra work and time. > > >> > > >> Thanks, > > >> > > >> Tom > > >> > > >> > > > > > > > > > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JS |
last post by:
I am writing a C# app that needs to parse a sentence entered by the user
for a simple boolean search.
I need to capture all of the AND words that are not inside of double
quotes. However, I am...
|
by: Chris |
last post by:
How Do I use the following auto-generated code from The Regulator?
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated...
|
by: Chris Lieb |
last post by:
I am trying to write a regex that will parse BBcode into HTML using
JavaScript. Everything was going smoothly using the string class
replace() operator with regex's until I got to the list tag....
|
by: Tim_Mac |
last post by:
hi,
i have a tricky problem and my regex expertise has reached its limit.
i have read other posts on this newsgroup that pull out the plain text
from a html string, but that won't work for me...
|
by: Chris |
last post by:
Hi Everyone,
I am using a regex to check for a string. When all the file contains is my
test string the regex returns a match, but when I embed the test string in
the middle of a text file a...
|
by: Marcus |
last post by:
Hello,
I am trying to include the literal '\' (backslash) character in a regex.
I am not sure if I need to escape it, however...
From http://www.regular-expressions.info/charclass.html:
"To...
|
by: conspireagainst |
last post by:
I'm having quite a time with this particular problem:
I have users that enter tag words as form input, let's say for a photo or a topic of discussion. They are allowed to delimit tags with spaces...
|
by: natebruneau |
last post by:
I wrote this regex
<font>.*\((?<Inside>.*?)\)</font>
"<font(Hi there)</font></font><font(Hi there)</font><font(Hi
there)</font><font(Hi there)</font><font(Hi there)</font>"
However it only...
|
by: anglaissam |
last post by:
I have a regex that is designed to help improve readability for a html document. "(?=((?!<\/?em).)*<\/em>)
The purpose of this regex is to escape " marks from within <EM> affected sentences....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |