Posts Tagged ‘Asp Net’
Visual Studio 2008 SP1
I’ve just installed and configured Visual Studio 2008 Service Pack 1. This is still in BETA but I was anxious to install and try it because of a bug fix that Microsoft were putting in after I logged a bug report with them in January. You can find that here if you want http://www.trstechnology.com/blog/asp.net/index.php/visual-studio-2008/
The bug fix was specifically to allow the use of a remote IIS Server. The initial version only allowed you to specifiy a local IIS Server.
I’ve just tested it and it works perfectly! Thanks so much to Bill Hiebert and Joe Cartano and the team at Microsoft for the fix.
Here’s the new option on the web properties tab;
ASP.NET Machine Generated Code
I just started working with a new client in Port Charlotte. They have had a website built by a company in Tampa and how now parted company with that company, so to speak. So I pick up this system and start to go through the coding and it’s build etc, trying to get up to speed as quickly as possible. But something is not right. It’s a struggle, confusing, big, messy. I don’t know why…
 Well I eventually figure out that this website system, asp.net code, classes and modules, forms, and by golly the database and stored procedures have, for the most part be generated by a …. MACHINE! ARGHHHH.
Yes, thats right, the original developers are working with a software tool that allows them to work in plain english (I guess) with a client to spec out the system. They do their high level analysis etc, enter data into the software, press a button and voila! Here is your website sir!
This doesn’t include the design of the site aesthetically, the way it looks etc, which is actually quite nice…
So, what’s my point. Here it is… A machine generated system (i’m going back to database design days years ago when I used software tools to design databases) tends to be broken down into a very low level. What I mean by that is the mathematics and algorithms that do the analysis and create the design tend to go WAY TOO FAR! This means that you end up with a system that is very complex. It explains one reason why my new client decided to jump ship from the pervious developer. The initial development costs where quite low compared to the cost of ongoing development and support. The original developer ended up in the same position as I did. After producing the system with a software tool, they were left looking at it, pondering its complexity and wondering how it all works exaclty.
Asynchronus Socket Programming
I’ve recently done some TCP/IP socket programming. The .Net framework provides a some nice features for making asynchronus program calls. One of the most robust is TCP/IP Sockets.
It can be quite confusing at first to understand the way an asynchronous call and callback mechanism works. I find it easier to understand when I look at the flow of the call first. So here is an outline of the flow.
The basic framework of an asynchronus call is:
- Declare the socket
- Socket.BeginConnect with ConnectCallback address
- ConnectCallback.EndConnect
- Socket.BeginSend with SendCallback address
- SendCallback.EndSend
- Socket.BeginRecieve with RecieveCallback address
- RecieveCallback.EndRecieve
And these are the actual function prototypes for an asynchronous TCP/IP socket. This is the outline, I’ll post some real code in another post later.
Dim state As New StateObject
‘ Create a TCP/IP socket. Dim client As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) ‘ Connect to the remote endpoint. client.BeginConnect(remoteEP, New AsyncCallback(AddressOf ConnectCallback), state)
Private Sub ConnectCallback(ByVal ar As IAsyncResult) ‘ Retrieve the socket from the state object. Dim state As StateObject = CType(ar.AsyncState, StateObject)
Try ‘ Complete the connection. state.workSocket.EndConnect(ar) Catch ex As Exception End Try ‘now do the send ‘ Begin sending the data to the remote device. state.workSocket.BeginSend(byteData, 0, byteData.Length, 0, New AsyncCallback(AddressOf SendCallback), state)End Sub ‘ConnectCallback
Private Sub SendCallback(ByVal ar As IAsyncResult) ‘ Retrieve the socket from the state object. Dim state As StateObject = CType(ar.AsyncState, StateObject)
Try ‘ Complete sending the data to the remote endpoint. Dim bytesSent As Integer = state.workSocket.EndSend(ar)
Catch ex As Exception End Try
 ‘now recieve the response ‘ Begin receiving the data from the remote device. state.workSocket.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, New AsyncCallback(AddressOf ReceiveCallback), state) End Sub ‘SendCallbackÂ
Private Sub ReceiveCallback(ByVal ar As IAsyncResult)
‘ Retrieve the state object and the client socket ‘ from the asynchronous state object.
Dim state As StateObject = CType(ar.AsyncState, StateObject) Dim client As Socket = state.workSocket
‘ Read data from the remote device. Dim bytesRead As Integer = client.EndReceive(ar) Try If bytesRead > 0 Then ‘ There might be more data, so store the data received so far. state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead))‘ Get the rest of the data. client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, New AsyncCallback(AddressOf ReceiveCallback), state)Else ‘ All the data has arrived; put it in response. Â If state.sb.Length > 1 Then response = state.sb.ToString()End If
End IfCatch ex As ExceptionEnd Try End Sub ‘ReceiveCallback
I’ll post the state object class and in another post. I found the easiest way to maintain the connection and shut it down was to have the worksocket in the stateobject.
Visual Studio 2008
I’ve recently installed Visual Studio 2008 and related software. I was hoping to upgrade and start developing in it as soon as possible.
I’ve generally always been an early adopter, but didn’t move to Visual Studio 2005 until quite late in it’s life cycle. I’ve since decided that was a mistake. It’s far better to be on the curve early than to come in late, or even miss a version and come in a versiion behind. Not a good idea.
Now, I know that Microsoft, God bless them, have had a really hectic schedule with the release of Vista and now Server 2008 and SQL 2008 coming soon. But, for heavens sake, I have a problem with using Visual Studio 2008 in my development environment and it’s a show stopper.
I always develop against a remote Windows server using IIS etc. That is so that I’m effectively running up against an environment that is pretty close to production. I haven’t had any problems with this for the last 4 years.
 I installed Visual Studio 2008 and tried to convert an existing project and VS couldn’t seem to access the development share. I then tried to create a new web application project with the same results.
 I’ve posted a thread on the ASP.NET forum. No replies to that yet…
And I’ve posted a bug report with Microsoft. I know that all environments may be configured slightly differently but if it’s working in Visual Studio 2003 and 2005 I certainly expect it to work in Visual Studio 2008. What a bloody pain!
Parsing Google Maps HTML
If you cannot afford 10 grand for an enterprise version of the Google Maps API, then you might be stuck having to parse the html form the clunky old maps.google.com website. If that is the case, here’s a snippet of code that seems to work consistently to parse out the lat and lon from the html.
 If HTML.Length > 0 Then ‘we have something back so ‘get important part of string Dim s1 As String = geo.Substring(geo.IndexOf(“viewport:{center:{“), 200) Dim intStartPos As Integer = s1.IndexOf(“{lat:”, 0) + 5 Dim intEndPos As Integer = s1.IndexOf(“}”, intStartPos) Dim intCommaPos As Integer = s1.IndexOf(“,”, intStartPos)
‘now assign the strings to lat/ lon vars _lat = s1.Substring(intStartPos, intCommaPos – intStartPos) _lon = s1.Substring(intCommaPos + 5, intEndPos – (intCommaPos + 5))
End If
Telerik RadGrid for ASP.NET
I was lucky enough to get a great deal on the RadControls for ASP.NET by Telerik recently.
I’d been looking at their RADEditor offering as a replacement for my Content Management System rich text editor. The editor looks awesome and supports lots of browser versions, whereas my editor only works in Internet Explorer (its quite old now(the editor not IE)).
Anyway, I leaped into the RADGrid and began to put it into a project but stumbled upon a problem where I couldn’t get an event to fire. This has been quite a pain in the butt! I finally worked out the problem a few days ago and wanted to share it here in case anyone has a similar issue.
The RADGrid is fantastic and very powerful. It is in fact, huge in terms of it’s functionality and capabilities. After I’d got the grid loaded with data, I wanted to edit a row and save that data or add a new row. At this point I had a problem where I couldn’t get the some of the grid editor events to fire. Specifically the Update and Cancel events of the edit form.
You can find the full post and responses at the telerik forum.
I had thought it was maybe a ViewState problem, which it turned out to be. Even though I had enabled viewstate in properties I found I had to explicitly enable viewstate in the asp.net tags of each form, usercontrol and control that was in the loaded control hierarchy.
It works like a charm and I’m very happy with the results. I’ve only just scratched the surface and I’m looking forward to developing more solutions with this control.
Essential Objects – Treeview
I’ve just finished a web project that I used the Essential Objects TreeView control.
I had thought initially that it would be relatively easy to configure. I’ve used a number of Essential Objects controls before and always found them fairly intuitive to use.
However, the TreeView was anything but intuitive. At the designer level it looks pretty straightforward. Just like the Tabstrip I thought. And initially all seemed well. But I had a real problem making sense of the data binding. Of course, its data driven so that would be a problem.
I thought I’d got it sorted out fairly early on, and then I realized that the data binding of each node was not what I expected.
The programming examples for the Treeview are, unfortunately non-existent on the essential objects website. Instead, they refer you to the menu control examples. This was pretty frustrating, as I was on a tight deadline and just wanted a Treeview example, nice and straight forward like. Please feel free to post this if you want.
So, this is how I bound the Treeview and got the correct itemID’s established.
Private Sub tvCookClass_ItemDataBound(ByVal sender As Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles tvCookClass.ItemDataBoundTry ‘set the itemid based on the dataset array index e.NavigationItem.ItemID = CType(e.NavigationItem.DataItem, DataRow).ItemArray(0).ToString If e.NavigationItem.Level.Equals(1) Then ‘this is the student level data ‘position 4 is the class data for each payment e.NavigationItem.Value = CType(e.NavigationItem.DataItem, DataRow).ItemArray(4).ToString End If Catch ex As Exception End Try End SubÂ
One really neat feature is the customItem control. This allowed me to quite easily embed an editor feature inside the Treeview. This was a relief after the problems I had binding the thing in the first place.
This is what the maintenance list looks like;

This is what the editor looks like. You just click on the row to display the editor.

So eventually I got a pretty neat solution using this control. It will require some work to get the thing looking a little better. I might even look at changing the editor so it goes below the selected node, rather than right next to / over it. But it’s nice to be able to update or edit the data with a couple of mouse clicks, without posting to a different form.
I would definitely use it for other projects. I didn’t have time to put it into an AJAX wrapper but next update I’ll try that too.
Visual Studio 2005 Upgrade
When I first installed VS 2005 I did so with a version prior to SP1. This created a problem for me when I tried to upgrade a project from VS2003 to VS2005.
I didn’t know that Microsoft had created a new “website” project template, which had replaced the 2003 web application.
The first point to note here is that there must have been hundreds of thousands of web applications already in existence and no doubt many thousands of developers waiting for the new release and eager to upgrade. It must have been very disappointing; well actually, very frustrating to try and upgrade and find out that your good old reliable web application was superseded by a “website” project.
This is one of the things that really annoys me about Microsoft. They are so eager to make the tools available to anyone with half a brain and an inkling that they might be able to program or develop systems. What they end up doing is trying to hide any levels of complexity to make the tools easier to use. This is not always a bad thing, hell, I don’t want to go too low level, I’m not that smart! But, they created a new website project template, trying to make the tool easier to use and at the same time, seem to have thrown the old web application model away?
Anyway, the web application model was provided by a plug-in (snicker) and in VS2005 SP1 it’s actually a template.
So, after an initial attempt and then looking at the ensuing mess (web application upgraded to website project; believe me, that isn’t a pretty sight!), I was able to upgrade fairly well after installing VS 2005 SP1.
I really had few problems after that. Quite a few warnings about obsolete syntax errors, which I updated in short order.
One interesting problem that did arise was trying to debug the project after conversion. I obviously changed the web server settings to use .NET 2.0 instead of 1.1. I then couldn’t debug the project until I had setup a separate application pool for the wp3.exe process. It seems you can’t run the old .NET 1.1 and .NET 2.0 processes side by side in the same application pool.
So I’ve been developing a new system in VS 2005 and have immediately found the new master page addition to be extremely useful. I’ll explain that in a future post.
Visual Studio, SQL Server et al upgrades…
So its been a fair while since my last blog post and boy have I been busy. Here are a few items that I have to write about soon, so as not to forget what the hell it is I’ve been so busy with lately.
- Upgrade to Visual Studio 2005 (yes I know this may seem long overdue but I think my timing is about right)
- Upgrade to SQL Server 2005
- Upgrade of an existing ASP.NET project from VS 2003 to VS2005 (man, I can’t believe what a pain in the arse this has been)
- System development update. Its been a busy month, as you can probably tell…
Well, the good news is that I’ve done all of the above and everything is working well.
The upgrade to SQL 2005 was fairly straighforward actually and yes, I’m running both SQL 2000 & 2005 happily on the same server.
The Visual Studio upgrade was less than satisfacory. Especially as I installed a version pre SP1 and then found that VS 2005 pre SP1 had a totally different concept of what the structure of a web project should be, so when I tried to upgrade an existing project from 2003 to 2005 the result was an utter mess. I then found that the in order to create a VS 2003 project in 2005 there was an add-in? A freakin add-in Microsoft? WTF?
I then found that VS SP1 had the add-in built in (YEY! Way to go MS!), so I ripped the offending pile of cack that was VS2005 pre SP1 off my PC and installed VS 2005 sans SP1. This was much more satisfactory.
I then opened an existing project and it coverted into what resembled an ASP.NET web application. I don’t know what MS was thinking when they created the new website project (well, actually I do and I’m going to save that rant for another post).
Anyway, I now have VS2003 and VS2005 IDEs installed and happily co-existing, which is a real plus. Also, the SQL Server 2005 client tools, which used to be called enterprise manager, are installed on the same PC as the old Enterprise manager and they both work fine. The bset thing is that I can use the new SQL 2005 client tools to administer both 2000 and 2005 databases, good stuff.
I’ve been putting this off for as long as possible, but had to bite the bullet mid 2007 as VS 2008 and associated .NET platforms will be with us soon and I didn’t fancy the idea of ugrading from Visual Studio 2003 to 2008 (nightmare!)
Bulletin Boards / Membership Site Systems
I’ve been looking at some bulletin board systems recently. I want something that I can easily integrate into existing sites and new sites that I’m putting up.
I looked at phpBB which has been around for a while and seems to be well liked. It’s also free, which is nice… I was toying with the idea of that and then looked at vBulletin, which is another that is highly regarded, Mark Joyner uses it so it’s good enough for me! It costs $180 for a site license, so it’s not too bad price wise…
Both of these are PHP systems with mySQL on the backend. Then I looked as some ASP systems. Web Wiz Forums looks pretty good and megaBBS gets a lot of good reviews too.
There’s also a WordPress plugin called bbPress that looks OK. Seems like it might be in fairly early stage of development though.
Anyway, I’ve got a number of systems running PHP on Windows 2003 with mySQL on the backend. No problems there, but PHP isn’t a language that I develop in, so I’m really looking for ASP or ASP.NET.
If you have any recommendations or experience of these products, or others that you know of, please let me know…
Thanks Steve
Oh, look what I found here at Wikipedia for ASP Forums and PHP Forums and this is a review site I was looking at earlier.

