ASP.NET, it’s Perfomance and JavaScript
When creating a solution with ASP.NET we should shift our mind. Most of the component make our life easier, I bit supprise when a developer don’t know SqlObjectDataSource / ObjectDataSource, which a valuable component that should be use when you’re going to ASP.NET 2.0.
The presentation is presentation layer, why don’t keep it that way?. I am not hardcore programmer like the mighty C++ programmer whom able to program in unmanaged code / MFC. Those people are top notch even compare to Java programmer. I am positioning my self as practitioner programmer, most of my time just think the logic not how to manage memory and use threading especially working in ASP.NET or PHP environment.
HTTP is stateless, is still stateless and that’s the beauty of HTTP. ASP.NET save the state using their own method like VIEW STATE which enlarge the HTML output. If you’re great developer you won’t think to much how to get rid of VIEW STATE since it’s very usefull in ASP.NET 2.0, why don’t make a setup to the IIS and make something called Compression being enabled?. It cost less and efficient. OSI layer must keep in our mind as we move on to Web programming, Web Server have big influences to Web.
Okay, I just want to share that I get bit confused when mixing non ASP control a.k.a HTML form component like <input> to be JS controller for other ASP control. Hell, if you working with non MASTER PAGE (this ASP.NET 2.0 feature), you will be happy ever after. You know that ASP.NET would render all Response.Write BEFORE touching the component, it’s beyond of Page_Load Event and PostBack. Okay, I give you an example :
<Asp:textbox id=”textboxUser” runat=”server”/> <input type=”button” name=”xyz” onclick=”ShowUserName(‘textboxUser’)” />
Let’s pretend that we use Master Page. Okay we have code in Javascript (we use IE) :
<script type=”text/javascript”>
function ShowUserName(controller) {
var obj = document.getElementById(controller);
window.alert(obj.value);
}
You will get error … yes, you will get error!. Why? because we using MasterPage, so the real ID is not textBoxUser but ctl00_ContentPlaceHolder1_textBoxUser. You could specify it manually, like :
<Asp:textbox id=”textboxUser” runat=”server”/> <input type=”button” name=”xyz” onclick=”ShowUserName(‘ctl00_ContentPlaceHolder1_textboxUser’)” />
but, this isn’t good because sometime you want rename the ContentPlaceHolder1 into ContentPlaceHolderXYZ, then you will get crash. You know what will be happen next, you must rewrite ALL control ID in your onclick event. There’s some elegant way, and you won’t deal with Response.Write(). You could use <%= textboxUser.ClientID %> and we need to add this to our input button onclick event :
<Asp:textbox id=”textboxUser” runat=”server”/> <input type=”button” name=”xyz” onclick=”ShowUserName(‘<%= textboxUser.ClientID %>’)” />
and you’re done. So, if you bos doesn’t like postback and I don’t know why they think postback will be happen when OnClientClick is rendered as OnClick at the browser which doesn’t create a postback, and love to use the hardway. Please don’t hesitate to show up your self to you bos that you could done a wrecking ASP.NET 2.0 fundamental.
Don’t think that Ajax will create a “Wow” functional experience, it could wreck. If you’re running business a dollar means a lot, you should see this page http://ajaxian.com/archives/accessibility-use-ajax-get-sued. AJAX will help user, but for high transaction business, leave it to HTML Form, using PostBack will save your day. I will be safer, traditional is old-school but safer!.
Happy hacking the ASP.NET 2.0 and wait a second, you will go to ASP.NET 3.5. Tell your mate at your IT/IS Solution company who love DataList especially in Indonesia to begin learning about GridView and the DataSources component. ASP.NET is growing. And tell them not to use CodeSmith which is confusing, because they never write the code and force them to use ObjectDataSource which built-in in your Visual Studio 2005. I recommend SubSonic rather than CodeSmith as DAL.
Sorry, comments are closed