James Avery’s Going Independent discussion group – level 000

If you haven’t already heard, James Avery has started a Yahoo group dealing with the topic of going independent (quiting your job while continueing to work).  There are already 90 members in the group, so there should be some good content and advice for those inclined to get out from behind a corporate firewall that blogs everything useful on the net.  Heres the group: http://groups.yahoo.com/group/going_independent/

Web Application architecture preference – level 300

I’d like to share my preference in building web applications.  First, I’d like to remember that in ASP 3.0, every page posted information to another page, so every page had to know the URL to the next page.  This created spaghetti-posting, and the web application became very brittle because if a page moved, other pages declaratively linking or posting to it were broken.  Those who implemented large web applications with ASP 3.0 know exactly what I’m talking about.


With ASP.NET the potential for that problem still exists, but some simple design decisions can save  you maintainence time down the road.  Specifically, I’m talking about putting all visible elements and logic in user controls.  I, personally, don’t implement any UI in my .aspx files.  All my .aspx files are there for is to hook up .ascx files.  This makes for no URL binding, and my control flow is all programmatic.  All my screens are different user controls, and a master user control decides which controls to load for a particular screen.


VS has some really great RAD features that make slogging out code very easy, and you will have a working application very quickly, but your maintainability will suffer.  Since I’ve been using my user control method, my apps have been extremely easy to maintain even in the face of changing requirements and design change requests.  Give it a try.


In ASP.NET 2.0, imagine have a .aspx that sets the master page, sets the thems, and then loads a user control.  In this way, your site is VERY flexible.  Your custom screen (user control) could be moved to any page anywhere in the site as well as adapted to different looks by changing the master page and theme.

How to: Add a totals row to your DataGrid before the footer/pager – level 300

In my own dealings, I’ve had to take control of how a DataGrid was rendered. One particular example is adding a Totals row to a grid BEFORE the footer. Here’s a sample:

<asp:DataGrid ID=”dgd” Runat=”server” AutoGenerateColumns=”False”>

<Columns>

<asp:BoundColumn DataField=”Product” HeaderText=”Product”/>

<asp:BoundColumn DataField=”Price” HeaderText=”Price” DataFormatString=”{0:C}”/>

<asp:EditCommandColumn EditText=”Edit” UpdateText=”Update” CancelText=”Cancel” />

</Columns>

</asp:DataGrid>
And the code:
        private void Page_Load(object sender, System.EventArgs e)

{

//creating mock table for data

DataTable dt = new DataTable();

dt.Columns.Add(“Product”);

dt.Columns.Add(“Price”);

dt.Rows.Add(new object[]{“Shoes”, “12.90”});

dt.Rows.Add(new object[]{“Socks”, “3.50”});

dt.Rows.Add(new object[]{“Underpants”, “8.40”});

//binding mock data

dgd.DataSource = dt;

dgd.DataBind();



//adding totals row

DataGridItem row = new DataGridItem(-1, -1, ListItemType.Separator);

TableCell cell = new TableCell();

row.Cells.Add(cell);

cell = new TableCell();

//calculate total

decimal total = 0;

foreach(DataGridItem dgi in dgd.Items)

{

total += decimal.Parse(dgi.Cells[1].Text);

}

cell.Font.Bold = true;

cell.Text = total.ToString(“c”);

row.Cells.Add(cell);

cell = new TableCell();

row.Cells.Add(cell);

dgd.Controls[0].Controls.Add(row);

}
I merely create a new DataGridItem, add what I want, and add it to my grid. I’ve used this concept several times, and I hope it helps out someone else.

Submit your Whidbey bugs (here’s proof it works) – level 200

Check out bug  FDBK13913 on the MSDN Product Feedback Center.  I submitted this bug after trying to convert a VS 2003 web application to Whidbey Beta 1 using the built-in convert project wizard.  Because of the change from code-behind to code-beside, this project is incompatible with Whidbey if unchanged.  Yes, there are workarounds, and I used one, but I submitted this bug because that’s what it is, and The Web team is working on the bug now.  I’ve submitted some bugs that were duplicates, but this one was unique, so if I didn’t submit it, who knows if someone else would?

Using VS 2003 & VS 2005 Beta 1 together – level 200

I’ve been using VS 2003 since I upgraded from 2002, and I’ve been using VS 2005 Beta 1 for about a month, and I’d like to share my experiences.  I have them installed side-by-side on my laptop, and they play fine together, but when I installed 2005, the v2.0 ASP took over my IIS apps, so I had to run aspnet_regiis to set it back to v1.1.  This problem is solved with 2005 because it doesn’t need IIS, and I don’t use IIS with it.  When you run a web site in 2005, it starts a built-in webserver that runs on a random high port for just as long as you need it too.  This is independent of IIS.  Because of the dynamic compilation model of code-beside, I don’t have to rebuild every time I modify page code.  That’s nice.  VS 2005 Beta 1 has some performance bugs in its build process, however.  It’s a bit slow compared to 2003, but it’ll get better.  I never realized how spoiled I was with 2003 since it builds so fast (of course this should be expected).  2005 will get there, but for now I have to wait for every build.  Also with my 2003 web apps, every time I rebuild, I have to wait a while for the web app to recompile and serve up the page again.  With v2.0 Beta 1 this restart/recompile process seems to be improved because the wait isn’t as long.


Bottom line:  VS 2003 and VS 2005 work well running side-by-side, and I even reference an assembly build in 2003 with 2005 (proof of version interoperability).  I have version 2 classes that inherit from v1.1 classes.  Seamless.

blogs.msdn.com’s usability just went down the drain – level 000

Sometime during the day on Labor day, the .Text engine running blogs.msdn.com and weblogs.asp.net changed for the worse. 


Now, in my RSS reader, if a post is over a few lines long, the rest gets cut off, and you see a very annoying (read more) link.  Now, it’s just like the news RSS feeds that give you a headline but make you click to see the rest of the article.  They want a visit to the website so that the advertising dollars come in.  I have no idea what this change is supposed to accomplish but to lower the number of readers of weblogs.asp.net.  I know that I don’t click on “read more“ links, and I’m really glad that .Net Junkies doesn’t do this. 


I want all the content in my RSS Reader, not on a website.  That’s the point of aggregating instead of “headlining“.

VS 2005 Beta 1 w/ ASP.NET – level 100

One thing that is very important to know about ASP.NET development:  To get intellisense on web controls, you must have the .aspx file open.  Since the code-behind has changed to code-beside, your code file is not a full class but a partial class, so if you have a textbox in your aspx (txtInput), the variable doesn’t have to be declared in your code file.  You can just type txtInput.Text = “foo”; in your code file, BUT if you only have the code file open, you won’t get intellisense on the TextBox.  To get intellisense for web controls on your web form, open the aspx file.  This threw me for a bit until I figured out this quirk. 

I’m skeptical about Experts-Exchange – level 000

I was just combing through my referral logs, when i saw a link to my “How to track down memory leaks” post coming from Experts-Exchange.  That means that someone is paying to see a solution to a problem that just refers them to my blog.  Has anyone reading used Experts-Exchange?  For one, I find that those who claim to be an expert are often times not, but the real experts don’t claim it, they are attributed this title by their peers.  Charles Petzold (whom we can all agree is an expert on Windows programming) is an example of this.   If you listened to hime on .Net Rocks a few weeks ago, it’s obvious.


In my experience, I’ve been able to find solutions to my problems on the free Internet without having to pay an aggregation service.  I contribute to newgroups more often than I post questions, and I can only hope that my blog is helping some people.


I have big reservations about this pay service that seems to be getting bigger.  It would be harmful to the development community if more and more useful resources became pay-per-view.