473,410 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Stupid c# question

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?
Nov 17 '05 #1
1 1214
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?

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
5
by: raz | last post by:
Greetings all. I apologize for what is almost certainly a stupid question, but I can't figure this out, and have no more time for head bashing... The short version: what is the appropriate...
4
by: IS | last post by:
At the recommendation of several people in this newsgroup I have downloaded two or three Compilers. One is the Beta version of Microsoft's Visual C++ 2005. I have entered a complete beginner code...
2
by: Ron Weldy | last post by:
I read that you don't need .cs files to deploy but I suppose if you are trying to reconstruct someone's work, you will need these files. Is that correct?
3
by: rroman | last post by:
I have a very simple form, takes information from the user, updates a SQL database, now I just want to redirect to a "Thank You For Your Time" web page within the same bowser. ASP. NET VB
6
by: Adam Smith | last post by:
I have posted this and similar questions repeatedly and can't even raise a single response. I am being led to believe that this then 'Must be a stupid question' although people say that there is no...
5
by: Alberto Salvati | last post by:
Hi, List. My company has a VERY BIG product base on db2 udb v7.x. We want to di an upgrade to v9, but.... current db has a lot of procedure (cobol..!). Therefore, we've planned to rewrite this...
2
by: Lynx101 | last post by:
Hi, Is this a stupid question? Senario: Two tables linked together with an ID number. Question: When using a combo box, which refences another table by indexed autonumber, is there a way to...
9
by: AWW | last post by:
Running XP - Visual Studio 2005 - VB Want to have duplicate projects - one safe and stable - other for experimenting Can't fine easy way to make duplicate project. Stupid question? or stupid ME?...
9
by: Alec | last post by:
Sorry guys, stupid question.... Am no programming expert and have only just started using php for creating dynamic news pages. Then I see a dynamic website without the php extension. ...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.