Skip to main content

Posts

Showing posts with the label basic

How to cache query data in session scope in ColdFusion

Session scopes query caching - cache query data in session scope QueryCacheSessionScope.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Session scopes query caching - how to cache query data in session scope</title> </head> <body> <h2 style="color:Crimson; font-style:italic">ColdFusion query caching example: how to cache query in session scope</h2> <hr width="600" align="left" color="LightPink" /> <br /> <!--at first enable session management in application.cfm file--> <cfset Session.UserName="cfsuman"> <cfquery name="Session.Authors" datasource="cfbookclub" maxrows="2"> select AuthorID, FirstName, LastName from Authors </cfquery> <cfdump var="#Session#...

How to use NOT EQUAL operator in cfif condition in ColdFusion

Introduction In ColdFusion web development, control flow plays a critical role in dictating the behavior of web applications based on specific conditions. One of the most fundamental ways to manage this control flow is through the cfif tag, which allows for the evaluation of conditions and the execution of corresponding blocks of code. In this tutorial, we explore how to use the "NOT EQUAL" operator within a cfif condition. This operator enables developers to execute different blocks of code when two values do not match, making it an essential tool for implementing conditional logic in ColdFusion applications. This article will break down the example code step-by-step to explain the key elements involved, from defining variables to styling the output. By the end of this guide, you’ll have a better understanding of how the "NOT EQUAL" operator works within ColdFusion’s cfif structure, and how you can apply this in your own web development projects. Variable Declar...

How to use NEQ operator in cfif condition in ColdFusion

CFif NEQ operator cfifNEQOperator.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>cfif NEQ operator - how to use (NEQ) operator in cfif condition</title> <style type="text/css"> .divCSS { background-color:Crimson; color:White; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size:large; width:400px; height:60px; text-align:center; padding-top:10px; border:thick; border-style:dotted; } </style> </head> <body> <h2 style="color:SeaGreen; font-style:italic">coldfusion cfif tag example: how to use "NEQ" operator</h2> <hr width="575" align="left" color="LawnGreen" /> <br /> <cfset UserRole="Guest"> <div class="divCSS...

ColdFusion - How to use IS NOT operator in cfif conditional processing

CFif IS NOT operator cfifISNOTOperator.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>cfif IS NOT operator - how to use (IS NOT) operator in cfif conditional processing</title> <style type="text/css"> .divCSS { background-color:DeepPink; color:Snow; font-family:"Courier New", Courier, monospace; font-size:large; width:450px; height:75px; text-align:center; padding-top:25px; } </style> </head> <body> <h2 style="color:SeaGreen; font-style:italic">coldfusion cfif tag example: how to use "IS NOT" operator</h2> <hr width="550" align="left" color="DarkSeaGreen" /> <br /> <cfset PreferedColor="DodgerBlue"> <div class="divCSS"> ...

How to use variable prefixes in ColdFusion

ColdFusion variable prefixes VariablePrefixes.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>coldfusion variable prefixes - how to use in coldfusion application</title> </head> <body> <h2 style="color:DarkBlue; font-style:italic">coldfusion variable prefixes example: how to use</h2> <hr width="500" align="left" color="LightBlue" /> <br /> <!--enable session management in application.cfm file--> <cfset Variables.MyNumber=2> <cfset Session.MyNumber=5> <cfset Application.MyNumber=10> <cfset Total=MyNumber+MyNumber+MyNumber> <cfset TotalWithPrefixes=Variables.MyNumber+Session.MyNumber+Application.MyNumber> <table border="0" cellpadding="2" cellspacing="2" bgcolor=...

ColdFusion variables typeless feature

ColdFusion Variables are typeless TypelessVariables.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ColdFusion Variables are typeless - how to test variables typeless feature</title> </head> <body> <h2 style="color:SeaGreen; font-style:italic">ColdFusion Variables are typeless example: how to verify</h2> <hr width="600" align="left" color="DarkSeaGreen" /> <br /> <cfset TestNumber=5> <cfset TestString="20"> <cfset SampleMath=TestNumber*TestString> <cfset SampleString="First Number: " & TestNumber & " Second Number: " & TestString> <table border="0" cellpadding="2" cellspacing="2" bgcolor="OrangeRed"> <tr style="b...

ColdFusion number and date format mask

coldfusion functions masks FunctionsMasks.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>coldfusion functions masks - how to use masks in coldfusion functions</title> </head> <body> <h2 style="color:DarkBlue; font-style:italic">coldfusion functions masks example: how to use</h2> <hr width="450" align="left" color="LightBlue" /> <br /> <cfset Salary=1525> <cfset SalaryWithMask=NumberFormat(Salary,"$")> <cfset ToDay=DateFormat(Now())> <cfset ToDayWithMask=DateFormat(Now(),"mmmm-dd-yyyy")> <table border="0" cellpadding="2" cellspacing="2" bgcolor="DeepPink" width="250"> <tr style="background-color:OrangeRed; color:Snow; font-si...

ColdFusion dynamic variables

coldfusion dynamic variables DynamicVariables.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>coldfusion dynamic variables - how to create and use in coldfusion</title> </head> <body> <h2 style="color:DarkBlue; font-style:italic">coldfusion dynamic variables example: how to use</h2> <hr width="500" align="left" color="LightBlue" /> <br /> <cfset ColorName="Crimson"> <cfset "#ColorName#"="Red type color"> <cfdump var="#Variables#"> <br /> <table border="0" cellpadding="2" cellspacing="2" bgcolor="DeepPink" width="250"> <tr style="background-color:Crimson; color:Snow; font-size:large;"> <td...

How to get coldfusion DataSource list programmatically

Get ColdFusion DataSource list programmatically GetDataSourceList.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>DataSource List - how to get coldfusion DataSource list programmatically</title> </head> <body> <h2 style="color:Crimson; font-style:italic">DataSource example: how to get DataSource list</h2> <hr width="500" align="left" color="LightPink" /> <br /> <cfobject action="create" type="java" class="coldfusion.server.ServiceFactory" name="cfactory" > <cfset DSourceStruct=cfactory.getDataSourceService().getDataSources()> <cfset DSourceList=StructKeyList(DSourceStruct,",")> <table border="1" cellpadding="2" cellspacing=...

How to dump and get output server variables in coldfusion

Server variables serverVariables.cfm <!DOCTYPE html"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>server variables - how to dump and get output server variables</title> </head> <body> <h2 style="color:DodgerBlue; font-style:italic">coldfusion server variables example: how to get output</h2> <hr width="500" align="left" color="PowderBlue" /> <br /> <cfdump var="#server#"> <br /> <font style="font-weight:bold; color:SeaGreen; font-size:large;">example server variable Output</font> <br /> <font style="color:DeepPink; font-weight:bold; font-family:'Courier New', Courier, monospace;"> PRODUCT VERSION[#server.ColdFusion.PRODUCTVERSION#]: <cfoutput>#server.ColdFusio...

ColdFusion - how to create and dump Application variables

Application Variables application.cfm <cfapplication name="cfexample" clientmanagement="yes" sessionmanagement="yes" sessiontimeout="#CreateTimeSpan(0,0,30,0)#" > <cfset Application.Author.Name="cfsuman"> <cfset Application.Author.FavoriteColor="DeepPink"> <cfset Application.DSName="cfbookclub"> <cfset Application.Description="ColdFusion Example"> ApplicationVariables.cfm <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Application Variables: how to create and dump Application variables</title> </head> <body> <h2 style="color:Crimson; font-style:italic">ColdFusion Application Variables example: how to create and dump</h2> <hr width="600...

How to use PlaceHolder in asp.net

PlaceHolder Server Control PlaceHolder is an asp.net web server control which used to store dynamically added web server controls on the web page. By using a PlaceHolder control we can dynamically add Label, TextBox, Button, RadioButton, Image, and many more web server controls in an asp.net web page. PlaceHolder server control act as a container control to store server controls that are dynamically added to the web page. PlaceHolder control does not provide any visible output. We only can see the dynamically added server controls inside a PlaceHolder control as child controls. We can add, insert and remove server controls programmatically in the PlaceHolder control. The following asp.net c# example code demonstrates to us how can we add server controls dynamically in a web page using PlaceHolder web server control. In the below example code, we put a PlaceHolder server control by declarative syntax. We also create a Button control with ...

How to use QueryString in asp.net

QueryString in asp.net QueryString is an alternate and popular way to pass variables between web pages. A page can pass variables with values and another web page can retrieve the variables and their values. We can declare query string variables in an anchor element. We also can pass one variable or multiple variables at a time within an anchor element (HTML link). To pass multiple variables using QueryString we need to use the '&' separator between variables. Each variable contains its value that we need to assign by an equal '=' sign. this is an example URL to pass variables using the query string. http://www.asp.net/Image.aspx?ImageID=1&ImageName=Elephant In the above example URL, we separated the original URL and QueryString by a question mark '?' separator. Then we declare a variable name ID and assign its value to 1 by using an equal '=' sign. We also added another variable name 'ImageName' and its value ...

How to use Table in asp.net

Table Web Server Control ASP.NET Table web server control displays a table on a web page. It is a .NET web server control so we can program it in server code such as add, and remove table rows, and cells programmatically. TableRow and TableCell web server controls allow us to display content for the Table. Table server control displays tabular data and we can format Table server control using its built-in methods and properties. The big difference between HTML table and asp.net Table server control is that we can manipulate Table server control using an object model. Generally, we should use Table server control when we intend to add or remove rows and cells (columns) programmatically at run time. Table server control acts as a parent (container) for TableRows controls. Table control's Rows property is a collection of TableRow objects. Each TableRow control has a collection named Cells. Cells collection contains TableCell objects. Actually, table serv...

How to use DetailsView in asp.net

DetailsView Web Server Control DetailsView is an asp.net web server control. DetailsView displays a single record from a data source. DetailsView provides a way to show, edit, update, insert, or delete a single record at a time. This control displays each field of a record on its own line. Sometimes .net developers use DetailsView in a master detail page. Typically this control is used for updating and inserting records. DetailsView updating, inserting, and deleting records tasks depend on the data source control capabilities. DetailsView does not support sorting. This control supports paging. DetailsView creates a user interface for paging if we set the AllowPaging property value to true. The .net developers can populate a DetailsView with data using many data sources control such as SqlDataSource, LinqDataSource, and ObjectDataSource control. DetailsView provides a UI that allows users to update a bound record. An editable view displays an a...

ASP.NET Web.sitemap file Example

A sample Web.sitemap file Web.sitemap <?xml version="1.0" encoding="utf-8" ?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="Default.aspx" title="Home" description="Home Page"> <siteMapNode url="StandardToolBox.aspx" title="StandardToolBox" description="StandardToolBox Controls"> <siteMapNode url="AdRotatorExample.aspx" title="AdRotator" description="AdRotator Example" /> <siteMapNode url="BulletedListExample.aspx" title="BulletedList" description="BuulletedList Example" /> <siteMapNode url="ButtonExample.aspx" title="Button" description="Button Example" /> <siteMapNode url="CalendarExample.aspx" title="Calendar" description="Calendar Example...

How to use MultiView control in asp.net

MultiView and View Server Control MultiView is an asp.net web server control. The View control is also an asp.net web server control. But view control always is contained within multiview control. Both multiview and view control act as a container for other controls and markup. Only one view can be defined as an active view in MultiView. MultiView ActiveViewIndex property specifies the active view within view collections of a multiview. Only active view control is rendered to the page. We can navigate views by setting the multiview ActiveViewIndex property value. ActiveViewIndex property holds the specified view's index number. MultiView control can include navigation buttons that we can add to each view. We can create a navigation button by adding any Button, LinkButton, or ImageButton server control to each view. For that, we need to set the CommandName and CommandArgument properties of each view. Reserved CommandName values are NextView...