Dot.Nut

Friday, January 20, 2006

DataSources in .net 2.0

It is damn ez in asp.net 2.0 to access data, thanks to the DataSource controls. There are the AccessDataSource for access databases, SqlDataSource for ANY OLE-DB compliant database, XmlDataSource for accessing XML data, and ObjectDataSource for biz objects (more on this later).

Any newbie can now juz drag a DataSource control from the toolbox and follow the wizard steps, and then choose the data-bound control and select this DataSource, and wham~ it is bound. no events, codes or anything to be written manually. All the settings are in the aspx, written by VS2005, including Select, Update, Delete and Insert statements. Even caching is supported intrinsicly by juz setting EnableCaching="true" in the datasource (SqlDataSource). damn.

But for more advanced apps which require n-tier, this might not be a best practice, especially the part where SQL is embedded directly in aspx. Well, the ObjectDataSource control is there for this purpose, which binds to biz objects. ObjectDataSource is in a later chapter, so after i go thru it, i will post my comments here :)

MasterPages in .net 2.0

When doing html for the websites, it is common to have a constant look and feel across pages, like header, menubar and footer. Having to make a change on a layout across all pages wasted time and it was common for developers to create include files for these pages. So the developer only had to update the include file to reflect the change across all pages. But include files were messy, non-standard and not supported in many visual IDEs.

MasterPages in .net 2.0 serves this issue well. It is essentially a control with contentplaceholder regions that "contain" other content pages, which could specify a MasterPageFile to dervive its container html from. the content page simply specify a master file to use, and use a content control with a matching ContentPlaceHolder ID as the master file's, then its all set to go. VS2005 supports masterpages in designer view out-of-the-box, but only for non-nested master pages.

Things to note:
  • MasterPages can nest, but designer view in VS2005 doesnt support
  • A Content control in a content page must have a matching ContentPlaceHolder ID with one of the ContentPlaceHolders the specified MasterPageFile
  • Content Page_Load fires 1st, then Master Page_Load > Content Control Events > Master Control Events
  • A Content page can access public properties defined in a master file. Use ((MasterPage)this.master).property or this.master.property if a <%@ MasterType TypeName="MasterPage" %> directive is specified in aspx.

Wednesday, January 18, 2006

my "1st" look at vs2005 and vwd.

well, here i go with my dive into asp.net 2.0. I absolutely loved .net 1.1, esp after my j2ee project, wahaha... lots of cool stuff which make my php frens go "that's cheating!!" well not everything about .net 1.1 was sweet for me... i came from a web designer background in dreamweaver and was very particular about my html code and layout. thing is, vs2003 kept "sync-ing" the HTML source with its own convention (all those MS-POSITIONING thingie) and made my head go bust. so in the end i used sharpdevelop, combo-ed with dreamweaver and CLRDebugger to develop web apps... haha, which was really slowing my progress, but still less troublesome then changing my html code all the time i update something on a form.

vs2005 kept its promise on not sync-ing the HTML wilfully! this was really a saving grace. on this point alone i could switch back to vs, but there are other cool stuff as well. now the designer and source view is click-sync, means the cursor goes to whichever line of html the designer has its focus on... intellisense is everywhere, yippee.

And the new code-behind model using partial classes is splendid! a net1.1 developer using vs2003 might not notice, but using code-behind without vs2003 was nightmare-ish... one side was the benefit of clear design-code separation, but the code-behind files done manually had to declare ALL of the controls used by the webform and kept in sync with any changes. partial class no longer has to account for this, making the code-behind file cleaner.

Other stuff in vs2005 include test server, mssql 2005 express, and so on and so on. well, i wun touch any stuff i am not experienced in... my next dive will be into masterpages, something i frequently used in .net 1.1 via wilson's masterpages, now integrated as a .net standard control :)

Nutting on this side of the blog?

Well, seeing my last post on this blog was on my skoo project using J2EE, really gives me ill feelings to write somemore.... haha. truth is I escaped from the "computer world" for a while to TW and have fun... look at my chiap blog for more info!

Well, I've graduated from my computing course and now am hunting for a job... guess i am taking my time huh... well, better find something i like than rush into something available and end up complaining all the time :P

Then, thanks to a prompt from shinchi, I've decided to take on the beta upgrade exam for MCPD web developer... since it's free and it counts to MCPD for existing MCADs, well hack why not. thing is, there isnt any study guide nor training course for this exam available yet (hence beta exam huh), and i haven't touch .Net for a while and a little rusty... further more the exam's for .Net 2.0 which I havent touch at all... damn.

So, I gotten myself a book on asp.net 2.0 to push myself to "catchup" to fellow developers (shit i hate the word fellow developers, makes me look dead-end)... murach's asp.net 2.0 upgrader's guide. It's good for any existing .net programmer i guess. simple to follow, clear examples and lists out lots of tips and notes. Well, if u wondering why i couldn't juz find some online materials on msdn or such, i am a lazy person who cannot read off the screen... yes, for a developer i cannot read off the stupid computer screen... damn my eyes hurt.

so, i will be posting stuff on this blog more often now, adding notes per chapter i go thru to remind myself on stuff and helping me for the exam!