Thursday, March 29, 2012
Separating application logic and content from its presentation
I am about to develop a simple Content Management system – main purpose
would be posting articles. I am trying to find some ideas/ sample
architecture showing how to separate application logic and content from its
presentation. I would like to use some kind of predefined templates (only
developer can cerate new templates); each template would be composed of
certain controls and in would have some specific layout. The default.aspx
would be created dynamically based on the template specified.
I checked out DotNetNuke and Community Starter Kit
(http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
too complex for my need.
Any hints would be greatly appreciated,
GregJust create the different modules (news, links, events, etc) and make sure t
o
use styles for all the different visual items. Then its really just a matter
of using different CSS files. You only have to specify which CSS to use then
.
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Greg" wrote:
> Hi,
> I am about to develop a simple Content Management system – main purpose
> would be posting articles. I am trying to find some ideas/ sample
> architecture showing how to separate application logic and content from it
s
> presentation. I would like to use some kind of predefined templates (only
> developer can cerate new templates); each template would be composed of
> certain controls and in would have some specific layout. The default.aspx
> would be created dynamically based on the template specified.
>
> I checked out DotNetNuke and Community Starter Kit
> (http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
> too complex for my need.
> Any hints would be greatly appreciated,
> Greg
>
Separating application logic and content from its presentation
I am about to develop a simple Content Management system – main purpose
would be posting articles. I am trying to find some ideas/ sample
architecture showing how to separate application logic and content from its
presentation. I would like to use some kind of predefined templates (only
developer can cerate new templates); each template would be composed of
certain controls and in would have some specific layout. The default.aspx
would be created dynamically based on the template specified.
I checked out DotNetNuke and Community Starter Kit
(http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
too complex for my need.
Any hints would be greatly appreciated,
GregJust create the different modules (news, links, events, etc) and make sure to
use styles for all the different visual items. Then its really just a matter
of using different CSS files. You only have to specify which CSS to use then.
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Greg" wrote:
> Hi,
> I am about to develop a simple Content Management system – main purpose
> would be posting articles. I am trying to find some ideas/ sample
> architecture showing how to separate application logic and content from its
> presentation. I would like to use some kind of predefined templates (only
> developer can cerate new templates); each template would be composed of
> certain controls and in would have some specific layout. The default.aspx
> would be created dynamically based on the template specified.
>
> I checked out DotNetNuke and Community Starter Kit
> (http://asp.net/Default.aspx?tabindex=8&tabid=47). They are very good, but
> too complex for my need.
> Any hints would be greatly appreciated,
> Greg
Seperating Business Logic From Presentation (Using Code Behind)
If i were designing a database driven application in Classic ASP i would write something like the following to access and display the data...
</CODE>
<%
Dim rs
Dim rsArray
Dim i
set rs = server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = Application("connStr")
SQL = "SELECT * FROM...."
rs.Open strSQL
if not (rs.BOF and rs.EOF) Then
rsArray = rs.getRows()
end if
rs.Close
if isArray(rsArray) Then
for i = lbound(rsArray,2) tp ubound(rsArray,2)
%>
<tr>
<td class="class1"><%=rsArray(0,i)%></td>
<td class="class2"><%=.....%></td>
<td rowspan=2><img src=...></td>
</tr>
<%
next
end if
%>
</CODE
Question... To my knowledge the point of code-behind is to seperate the Server-side Code from the Client-Side code.
To that end... how would you go about doing that in ASP.NET? It just doesn't make sense to me.
Even if you did a page_load event that accessed the data how would you then pass that data to the client side code so that you could format it and place it in a table with other client side objects in it like pictures? Or dynamically craete the name of the pictures in the table but doing somethign like <img src="http://pics.10026.com/?src=pic<%=rsArray...%>"...> etc
This part of ASP.Net completely confuses me.I presume i need to use one of the data controls?
Yes, you can use datagrids and repeaters to do the same thing. Get data from your datasource then databind to a repeater or datagrid.
You can also databind to all sorts of other controls (dropdown lists, check box lists, radio lists...)
and using those controls i can format/arrange my data as i want?
is there a simple coding example?
Yeah, the tutorials on this site have some examples.
You can format the data any way you want. It'll take some getting use to. You'd use data binding syntax instead of <% %>, which actually still feels like you're mixing code in with html... but it's supposed to be better somehow.