General NEWBIE advice: How much C# on ASP.NET screens?
Posted on 2006-04-12
Hi. My company is switching to C# and ASP.NET from Java and ASP (old). I’m the Java guy, and I’m keenly interested in how much we can bring the many excellent features of an object-oriented language like C# onto a web page driven by ASP.NET. (I’m basically a middle-ware guy with almost no GUI experience.)
I understand that ASP.NET allows both embedded C# and a separate layer of C#. I’m trying to understand how far we could go with that. I’m not so much interested in the mechanics at this point. Instead, I’m just looking for general guidance. If anyone wants to either answer directly, or point me to stuff I could read, that would be greatly appreciated…
So I have two examples.
EXAMPLE #1: A SIMPLE “CUSTOMER” DATA BEAN
I’m not sure if C# calls it this, but a data bean is a very simple class that exists basically just to hold data. So a customer bean would store Name, Address, Phone Number. It would look like this (simplified):
public class DataCust
private String custName;
private String custAddress;
private int custPhone;
Currently, in ASP (old), our GUI needs to create three separate “local variables” to store Name, Address and Phone Number. And then, when the user clicks elsewhere, three more “session variables” are needed to store that information—because the web site is “stateless”.
One great advantage of the bean is that you declare it once, and then anyone can pass it around and use it. So ideally, the GUI would pass this bean to my C# middleware, with no translation needed.
So QUESTION #1:
If we could replace those ASP “local variables” and “session variables” with this customer bean, would it PERSIST as the user clicked elsewhere? In other words, could this customer bean (which is an “object” from an OOP perspective) do what ASP session variables do: persist as long as the GUI user is “present”?
EXAMPLE #2: A SOPHISTICATED “BEAN HANDLER”
Basically, if you can have C# running in ASP.NET, how sophisticated can it get?
For example, I have existing code that I could C#-ize, which does a lot very handy things with beans, such as load them into various data structures automatically, translate rows from a table into beans, etc. Basically, it’s a full-fledged class—not some little widget. And it could easily and safely do a lot of things that take a lot longer to do in a language like VBscript.
So QUESTION #2:
In ASP.NET, could something like that “bean handler” exist more or less as is? (Please note the “bean handler” is just an example of “some sophisticated C# class…”). Would I be able to “instantiate” it with ASP.NET, tell it to go grab some data, etc. More importantly, could that “bean handler” (which is ALSO an “object” from an OOP perspective) PERSIST as long as the GUI user is “present”?
Thanks a lot!