CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Zone: > NEWSGROUP > Asp.Net Forum > migration_to_asp.net.migrating_from_cold_fusion_to_asp.net Tags:
Item Type: NewsGroup Date Entered: 11/6/2002 8:52:42 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 32 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
pnrrth
Asp.Net User
CFIF tag?11/6/2002 8:52:42 PM

0/0

In Coldfusion I could write something like this:

<CFIF something EQ 'true'>
<TD>
... {various HTML code}
<CFELSE>
<TD>
... {other HTML code}
</CFIF>

Is there any way to do something like this in ASP.NET? I know that you can create label controls and populate them with HTML code, but sometimes it is just easier to write out all your HTML code and not have to worry about escaping Quotes and that sort of thing.
--Tim
jtmueller
Asp.Net User
Re: CFIF tag?11/17/2002 7:19:55 PM

0/0

Techncially, you can do the exact same thing in ASP.NET, like this (VB.NET):

<% If something = "true" Then %>
<td>
.... {various HTML code}
<% Else %>
<td>
.... {other HTML code}
<% End If %>

However, the ASP.NET model strongly discourages this kind of mixing of HTML and application logic (which I think is a good thing). A more ".NET" way to accomplish this might be to manipulate the "Visible" property of a pair of server-side controls (with runat="server" attributes). For groups of controls or lots of HTML, you could enclose each group in an <asp:Panel> control, and manipulate the Visible property of the panels to only show one at a time based on whatever logic you needed. That way you can keep your layout in the ASPX page, and the code for manipulating that layout in the code-behind file. Note than when a server-side control has its Visible property set to false, the HTML for that control is not sent down to the client at all.
andylo
Asp.Net User
Re: CFIF tag?8/7/2003 5:30:16 AM

0/0

Then how about in C#??
ericy3kok
Asp.Net User
Re: CFIF tag?8/28/2003 5:16:59 PM

0/0

<quote>However, the ASP.NET model strongly discourages this kind of mixing of HTML and application logic (which I think is a good thing). </quote>

you're confusing "Business Logic/Data Logic" and "Presentation Logic"

so IMO these statements are perfectly valid "Presentation Logic", whereas the logic is simply determining what is being displayed, and since HTML is very much inline, it makes sense.
----
E.Newton
ASP.Net/C# Solutions Developer and Consultant
Ensoft Software
http://www.ensoft-software.com/
[email protected] (Remove the CC)
McMurdoStation
Asp.Net User
Re: CFIF tag?9/6/2003 5:34:21 AM

0/0

I agree with another post that you shouldn't write conditional C# or VB.Net program flow control statements in the HTML (aspx page). If you want to conditionally turn on or off a bit of HTML you should do it by toggling the visible property of some HTML element or ASP.Net control. You would then turn on or off the element from the code behind.

<!-- HTML -->
<TR ID="ConditionATR" runat="Server">
...some HTML code, ASP.Net controls, etc.
</TR>
<TR ID="ConditionBTR" runat="Server">
...some other HTML code, ASP.Net controls, etc.
</TR>

//C# code behind
bool showConditionA = whatever;
if( showConditionA ){
ConditionATR.Visible = true;
ConditionBTR.Visible = false;
}
else{
ConditionATR.Visible = false;
ConditionBTR.Visible = true;
}

In the end it all comes down to the same thing, whether the conditional code is in the aspx page or the code behind page. It's a matter of style where you prefer to see it. I personally like having it controlled from the code behind rather than CF style with the <CFIF> statements embedded in the HTML.
ericy3kok
Asp.Net User
Re: CFIF tag?9/13/2003 5:20:29 PM

0/0

I can appreciate your opinion, I had the same opinion for a while too.

But, I've since "moderated" it a bit,

- i save codebehind for the hard core database / file interaction stuff, stuff that wouldnt change during a website look and feel overhaul...

- most rendering logic is written inline [via <SCRIPT runat=server>], just because it's a ton easier to change, doesnt require the recompile of the codebehind

That's really the reason that I use the old style render blocks <% %> and expression blocks <%= %>

but frankly in your example, you'd see me write it into the page itself:

<SCRIPT runat=server>
bool showConditionA = whatever;

if( showConditionA ){
ConditionATR.Visible = true;
ConditionBTR.Visible = false;
}
else{
ConditionATR.Visible = false;
ConditionBTR.Visible = true;
}
</SCRIPT>

----
E.Newton
ASP.Net/C# Solutions Developer and Consultant
Ensoft Software
http://www.ensoft-software.com/
[email protected] (Remove the CC)
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Inside ColdFusion MX Authors: John Cummings, Neil Ross, Robi Sen, Pages: 864, Published: 2002
Macromedia Studio 8 All-in-One Desk Reference For Dummies: All-in-One Desk Reference for Dummies Authors: Damon Dean, Andy Cowitt, Pages: 888, Published: 2005
ColdFusion MX with Dreamweaver MX Authors: David Golden, Pages: 672, Published: 2002
ColdFusion MX Developer's Handbook Authors: Raymond Camden, Arman Danesh, Hal Helms, Guy Rish, Emily Kim, Shlomy Gantz, Jen deHaan, Peter deHaan, Selene Bainum, Charles Mohnike, John Colasante, William Baum, Kenneth N. Fricklas, Matt Liotta, Pages: 940, Published: 2003
Platinum Edition Using XHTML, XML and Java 2: Using XHTML, XML and Java 2 Authors: Eric Ladd, Jim O'Donnell, Mike Morgan, Andrew H. Watt, Pages: 1413, Published: 2001
Dreamweaver MX 2004: The Complete Reference Authors: Ray West, Tom Muck, Pages: 958, Published: -1
ColdFusion MX: From Static to Dynamic in 10 Steps Authors: Barry Moore, Pages: 400, Published: 2002
Dreamweaver MX 2004: A Beginner's Guide Authors: Tom Muck, Ray West, Pages: 544, Published: 2004
Macromedia ColdFusion MX Development Authors: Eric Ladd, Pages: 594, Published: 2002
Macromedia Coldfusion 5: Training from the Source Authors: Kevin Schmidt, Pages: 288, Published: 2002

Web:
cfif If the value of the expression in the cfif tag is True, ColdFusion processes all the code that follows, up to any cfelseif or cfelse tag, and then skips to ...
Cold Fusion Tutorial Part II Every tag must have a matching tag, the and ... When comparing values within the CFELSEIF and CFIF tags you may use the ...
Page 5 - Introduction to ColdFusion Markup Language If the variable#Url.date#is already defined, then the block of code between the opening and closingtag is executed. Otherwise, the block of code will ...
DWUser.com - CFFieldsFilled: CFIF Tag Creator/Editor - Dreamweaver ... CFFieldsFilled - CFIF Tag Creator/Editor. Price: $12.00 USD Tired of wasting time coding those pesky "Using a cfif tag to enforce business rules The cfif tag lets you create conditions that evaluate to either True or False. Therefore, to use the cfif tag to test whether a trip name was entered ...
CFIF tag? - ASP.NET Forums CFIF tag? Last post 09-13-2003 1:25 PM by ericy3kok. 5 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
ColdFusion - How Do I Write A Cfif Tag To Prevent Multiple DB ... ColdFusion - How Do I Write A Cfif Tag To Prevent Multiple DB Field Display. Get help with this and thousands of other programming and web ...
cfmail not working inside cfif tag : coldfusion The following code is causing a context validation error for CFIF tag the start tag must have matching end tag. If I take away the body of the email a just ...
Woork: Load pages using URL variables with Coldfusion cfinclude ... Oct 9, 2007 ... This post show how to load pages using Coldfusion URL variables with and tag. A coldfusion URL Variable is defined simply ...
CFIF tag? - ASP.NET Forums I personally like having it controlled from the code behind rather than CF style with the statements embedded in the HTML. ...




Search This Site:










private variables versus viewstate...

how to create a custom design panel

persisting simple custom class

problem with custom dropdownlist control

hosting asp.net 2.0 applications

server control postback problem

creating a control that other controls can be dropped in

help with a very simple custom control

specific url access for authenticated users

date picker control wanted with formatting

ms sql 2005 studio management express vs. full text search

write script tag in <head> in custom control

custom combobox

thread.currentthread.currentculture

how to create zip files

load control from given string type

how is this for colocation costs...

find out if a user is still connected

how "per server" license type could be made

need host with decent bandwidth and quick response time...

ipostbackeventhandler and ipostbackdatahandler

inherited method calls

how to get rows and columns collection in a data bound server control, independent of datasource attached.

do i have to compile my user control?

added child control is not rendered

extend existing control with left and top properties.

.net controls 2.0 > 1.1

choosing a cms - recommendations and advice

collection property's items in inner tags for datagrid

client side forms contol callback to javascript?

  Privacy | Contact Us
All Times Are GMT