The <%# ... %> tag enables you to run a bit of code compiled at runtime from
the ASPX page. You can use existing classes or you can write a method to do
the work in the codebehind and call your own code from the tag. You can
therefore write a method to do the string replacement you need and call it
using <%# myMethod(((DesktopAlert.Web.User)Container.DataIte m).Username) %>
where myMethod returns a string manipulated in the right way.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Buddy Ackerman" <bu**********@buddyackerman.com> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I'm trying to modify an ASCX written in C#. There is code embedded with
the HTML and some lines start with <%#, what is the # for (is it like <%=
in VB.NET)?
So, I have a line that looks like this:
<td><%#
Server.HtmlEncode(((DesktopAlert.Web.User)Containe r.DataItem).Username)
%></td>
However, I want to do a string replace on the Username so I tried to do
this:
<%
string username =
Server.HtmlEncode(((DesktopAlert.Web.User)Containe r.DataItem).Username);
username.Replace("Str2Replace", "ReplaceWith"); %>
<td><%# username %></td>
This little bit of code is inside an asp:repeater tag. When I make this
modifcation tha page nolonger displays anything it is completely empty
(even when I do a view source on the page there is nothing in it no HTML
tag, nothing).
What am I doing wrong?