Archive for the ‘Code’ Category

System.Web.VirtualPathUtility.ToAbsolute("~")  does the job of ResolveUrl on the server side.

I haven’t actively developed moBlog for sometime now. I think it has been about two years since I did anything on it.

But according to my box.net statistics, it is still being downloaded. At least once a day. And occasionally I get requests for features and asking me if I am planning on a new release.

I have been toying with the idea of open sourcing it for sometime now. I am not sure why I didn’t consider it from the beginning. I think it could have gained a lot of momentum had I done it before.

But as the saying goes, better late than never, today I am making moBlog open source. I am uploading the source to codeplex as I write this.

The codeplex url for moblog is: http://moblog.codeplex.com/

If anyone needs any help in setting it up just shoot me a line and I will walk you though it. I will add the instructions needed to get it working on to the codeplex site eventually, as soon as I get some time to write it.  I would also do a roadmap if there is still interest for new features.

If someone wants to join the team and develop the app I welcome you! It would also inspire me to contribute more.

The reason for moBlog becoming inactive was due to my shift from a WM device to an iPhone. That left me without a real device to test the application. When I did the shift I searched for a similar app for iPhone but found none that supported all the platforms that moBlog supported. There is an official WP app for WP blogs, but I couldn’t find a good free app that supported blogger and live spaces on iPhone. If anyone can direct me to one I would appreciate it.

Also, if there is a free version of an app that converts the .NETCF app to iPhone compliant code, I think moBlog will be quite popular among iPhone users as well. I was thinking about porting moBlog to iPhone but I don’t have a MAC to do the coding. So that idea never saw the light of the day.

 

Closing a fancybox

Scenario:

We are using a fancy box to present a form to the user to enter some data. Once this data is entered and the user submits the form, if the processing was successful, we want to show a message to the user and then close the fancybox (which is the form).

Code:

HTML

<a href="<%= ResolveUrl("~") %>RegForm" class="iFrameRegister" title="">Register</a>

Open the form:

$("a.iFrameRegister").fancybox({
        ‘frameWidth’: 400,
        ‘frameHeight’: 400
    });

Close the form:

parent.$.fn.fancybox.close();

Technorati Tags: ,,

I recently upgraded my VS2008 to Service Pack 1 which was a combined update to .NET Framework 3.5 also to SP1. I did update to try my hand in ASP.NET MVC architecture.

I am working on a couple of projects that are using ASP.NET AJAX these days. And after doing this update I started noticing strange issues in pages using AJAX extenders.

First I noticed that the pages containing the AJAX extensions were throwing strange errors. They were usually in the form of “Cannot set value True for property enabled”. This caught me quite by surprise and made me review the HTML over and over.

Once I was sure that there was nothing wrong in the way that the properties were set, and these were pages that were working perfectly, I realized something would have happened after applying the service pack. But I could not find a lot of useful information directly documenting this issue. Most of the issues were reported on the user controls behaving in a similar manner.

After quite a bit of Googling and putting 2 and 2 together I managed to solve it by applying ANOTHER hotfix. This is where I found most of the info from: https://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=361826

This is the hotfix that solved it for me: http://code.msdn.microsoft.com/KB967535

Hope this helps someone out there to avoid the mess I was in which resulted in a few hours worth of work just before a major deadline!

The mobile platform war seems to be heating up. So far, the dominant player was Symbian. But there are quite a few challengers to Symbians dominance. MS’s Windows Mobile is now a force to be reckon with. They are getting quite a good market share on the higher end smartphone segment.

Google is trying to grab their share of the pie with Open Handset Alliance and Android. There is LiMo, which is challenging Google and the established rest of established players as well. Then there is Apple with its phenomenal iPhone.

There in lies my problem. For quite sometime I have been convinced that mobiles are the future. I mean even if you just compare the numbers, there are far too many mobiles than computers. And apparently around 14 mobiles are sold in the world every minute. That means its growing.

The carriers also are now concentrating more on revenue from data and hence are promoting applications that will entice users to use more and more mobile applications. So if you are into software and are looking for new ideas, then mobiles are the way to go.

Most of the mobile platforms that are in use today are either proprietary or are Symbian based. Which makes my .NETCF skills more of a niche. Therefore I kind of figured that if I ever seriously consider developing a mobile application that has mass market appeal, I need to master Symbian (as of now). But with the emergence of all these new mobile platforms, is it the way to go?

What I would really like to see is MS making their WM platform open source, and then it becoming the defacto standard. That will push my .NETCF skills from being niche to mainstream. But that seems very unlikely, specially it is highly unlikely that they will make their OS open-source and secondly, even if they did….

But one thing is certain. I need to brush up my Java skills! Be it Android, Symbian or Limo, the common thing they share is the ability to write programs for them using Java! Man how I wish it was C# instead!

This post is to test the latest enhancements for moBlog for Smartphone with wordpress.com.

These enhancements came about as a result of listening to user feedback. Though moBlog only has a small user base, they have been pretty active in using the application, suggesting improvements and finding bugs, all of which would not have been possible, specially with the Smartphone version as I do not own an actual device.

I was earlier paranoid about releasing the software as I had not tested it on an actual device. But after reading “Getting Real” by 37Signals and also due to the limitation of me not owning a Smartphone device I was compelled to release it only after testing it on the emulator. And the user community has been wonderful in reporting issues and suggesting improvements for the application after test driving it in various devices.

Thank you Nick, Pat and all the others for finding bugs and suggesting improvements. Please do keep on sending your suggestions.

Let’s make moBlog THE mobile blogging software for Windows Mobile!

Posted from moBlog – mobile blogging tool for Windows Mobile

moBlog 2.1.0 had an error when you were trying to setup a profile for your Blogger.com account. This was due to a careless error on my part. Thanks so much to Hans and Pat who pointed out the error to me. I have now fixed it and have released version 2.1.1.

Enjoy moBlog with photo blogging support!

moBlog now supports Photo Blogging for WordPress and Blogger platforms!

It was the most requested feature for moBlog! Support for posting photos taken with device camera’s. As far as I know there aren’t that many mobile blogging applications that support Photo Blogging! Hope this feature will make moBlog THE mobile blogging application!

All you smartphone users, yes I hear you. You need a moBlog version that works on Smartphones! Hey, I’m on it! Your patience will be rewarded pretty soon! Now that moBlog is complete with photo blogging, I am on the task of converting it to work on Smartphones!

As usual, moBlog is still in beta. So please let me know if you come across any issues or have any comments! Looking forward to hearing from all of you!

Posted from moBlog – mobile blogging tool for Windows Mobile

The most requested feature for moBlog has been the ability to upload photos from the devices. Since most devices are equipped with a camera it makes perfect sense to enable photo blogging on moBlog as it will give people a quick way to get their photos in the devices to their blogs.

Of the blogging platforms that moBlog the easiest to get photo blogging working on was the on WordPress. WordPress supports Metaweblog API’s newMediaObject method and it worked like a charm. You can see the first photo uploaded from moBlog on the previous post!

Blogger now hosts the photos uploaded to the blogger.com blogs on Picasa Web Albums. The documentation vaguely mentioned something about Blogger creating a default album on Picasa for Blogger photos, but this web album is not accessible via the API. Hence I devised a crude method of creating an album for moBlog and uploading the photos to that album!

But the biggest disappointment was Live Spaces. Though they support Metaweblog API, their support of that is limited. Specifically they do not support the newMediaObject method. That was a pretty bad decision from the Live Spaces team. If they support a particular API, either MetaWebLog API or ATOM API, they have to support it completely. To make matters worse they do not provide any API to upload photos to the Live Spaces Blog.

I know that Windows Live Writer supports uploading photos to Live Spaces blog posts and similar to Google approach, those photos are stored in a seperate album on Live Spaces. But my problem was I was not able to find any documentation on the approach taken by Live Writer.

In any case, a new version of moBlog will be released in a couple of days with photo blogging support on Blogger and WordPress blogs. Along with that I will be releasing a few more enhancements to the post composition screen with the option to decorate the body of the blog posts.

Look forward to an enhanced moBlog!

Posted from moBlog – mobile blogging tool for Windows Mobile

moBlog is almost ready to be released to the public. This initial release will be released as a beta software as so far the only person who tested was me. Once I receive feedback from a few more folks who are willing to give it a spin, and fix any issues if there are any, then I will take the beta tag off it!

So far moBlog works with Blogger, WordPress and Live Spaces. From a technical point of view since moBlog works on both GData API (to support Blogger.com) and Metaweblog API (to support WordPress and Live Spaces). And technically moBlog will support any other blogging platform which has support for GData API or Metaweblog API. My intention is for moBlog to support as many blogging platforms as possible. If you there is any specific blogging platform that you need moBlog to support, please let me know and I will try to get it incorporated in a subsequent release.

We’ll this post is made from moBlog client itself. After a few more tests are done, hopefully within a couple of hours moBlog will have its official release!

I have been toying with the idea of creating a blogging application for the Pocket PC / Smartphone devices for sometime. i had done some extensive research on it sometime back, but due to limited time available for coding 4 fun (as I call my experimental coding activities) I had been pushing this idea away. But since I got myself a Windows Mobile phone, this need kept popping up.

My initial reaction was to go back to the applications that I had come across earlier and try them out on the phone. Well the fist one I tried refused to work on my blog unless there was an active Internet connection. This was a major limitation as I did not want to be online while I was writing my post. I know that GPRS/3G usage is charged for the actual traffic, but the downside was an active Internet connection on the phone drained the battery! So that experienced was very shortlived.

Then I did come across several other applications that allowed you to work offline, but I had small issues with them. Some I had issues setting up and running. They had exceptions. Some supported only one blog. I wanted something more as I have a couple of blogs. And I wanted my client application to support all of them without me having to delete and setup when I wanted to switch blogs.

 Also, I still had the urge to develop an application myself. With my involvement in GMobileSync now I was experienced in working with the GData API as well. So I went to work on my Mobile Blogging Application: MoBlogger.

Here are a feature list:

  • Multiple profiles
  • Multiple Blogs within a profile. So if your blogger account has multiple blogs setup, all of them will work!
  • Work Offline – you can work offline and save your posts for uploading later.
  • Supports labels.

Sounds great right? Well yeah… except right now it only supports Blogger! But I am working on supporting multiple blogging platforms! The immediate platforms on the radar are WordPress.com and Windows Live Spaces.

In the mean time if you would like to have a go at it, drop me a mail, I’ll be happy to send you an installation.

I have been busy and it’s not just been my work! I joined an open source project on codeplex. I had this idea to create an application that would sync a Google calendar with a Pocket PC’s Outlook Calendar. Then I was searching around to see whether there were similar applications around and came across GMobileSync which was an open source project on http://www.codeplex.com.

I requested the project’s coordinator to accept me as a developer and I was accepted. Then I took it upon me to fix a few of the bugs that were reported on the bug list. Then Eric, who is the creator of GMobileSync, told me that if I fixed two way sync, which is the most requested feature I will become the ‘hero’ of the GMobileSync world! That prompted me to put in my free-time towards fixing this issue / feature and last weekend, I managed to fix that. I made a release to codeplex and Eric has since released it to about 500 beta testers. And now I am awaiting for beta test results and keeping my fingers crossed that there wont be any bugs!

Working on an open source project has been pretty exiting. For one Open Source projects will give you the largest audience for your applications. Already the release I did has had 88 downloads for the space of one week. All this time the release was not even public. It was the beta testers who were invited to download and test. Hopefully the number will go up once the release becomes public.

GMobileSync has had about 40,000 downloads. Even if 10% were actively using the application, then that would mean 4000 people. You know it feels good to have an application where there is some little contribution of yours, being used by so many people. The difference in the open source world is that people will be appreciative about your work, unlike in commercial software. In commercial software, since they pay for the software, they tend not to show their appreciation!

If you had been looking for a tool that would sync your Google Calendar with your Windows Mobile device, then give GMobileSync 1.3.5 a try! And feel free to let us know your ideas for improvements or bugs!

Finally, thanks to Eric for accepting me into the project and letting me contribute. And to Lushi for tolerating my coding sessions that went into late in to the night 🙂

I came across the above error message when I was working with SqlCeResultSets today. I was executing a query and assigning values to a SqlCeResultset to bind the resultset to a combobox. But at runtime, when the resultset was bound to the control, I got the above error.

I could not figure out was causing it. My first take was to assume this was due to the fact that teh resultset was empty. But then that did not make any sense. When I looked into the code, i realized that I have created the resultset as ‘Scrollable’, when I was creating it. Then I changes the resultsetoption to ‘None’. This solved the problem.

I am not sure why Scrollable resultsetoption caused this error in the first place. Any ideas would be most welcome.

I figured it out.

You cannot have a non-scrollable resultset bound to a control. If the resultset is non-scrollable, the ResultSetView property becomes null and hence your data binding does not work.

Actually the issue was somewhere else. I had bound the resultset toa  combobox. And for the combobox, I had a selected index cahgned event handler, which was badly coded without any checks for the value that was selected in the combobox. Once I got that sorted out, the problem was sorted.

If you have developed and deployed .NETCF Pocket PC/Smartphone apps by creating the CAB files, then you would have wanted to do this.

You create the CAB files using ‘Build CAB File’ option. Then you copy the CAB into the device and install it. Now if you go to the Settings -> System Tab -> Remove Programs, you will see your application as “My Comany Application”, where application is your application name. For obvious reasons you dont want this to appear as ‘My Company’.

This is how you change it. THe CAB file build process is controlled by the Application_PPC.inf file, where Application is your applciation name. This file is in the obj -> Debug or obj -> Release folder, depending on the configuration that you use.If you open this file in Notepad you will see this part:

[Version]
Signature=”$Windows NT$”
Provider=”My Company”
CESignature=”$Windows CE$”

You can change the “My Company” above to your company name. That solves the problem!

IMP: Please note, if you use the Build Cab File option from within Visual Studio, then this file will get overwritten with a default file. And your changes to this file will be lost. Instead, to build the CAB files, use the BuildCAB.bat file. This will create the CAB files with the modified settings.

Hope this helps someone out there!

This is something I was trying for sometime and the only way I managed to do it earlier was by disabling the datagrid. The other solutions proposed were by sub-classing the datagrid control and by overriding the default behaviour. But I found a better and easy way described in this blog.

I am posting the code snippet here, just for my future reference as well as for anyone else’s benefit.

1. To handle mouse click events. When the user selects a cell by clicking on it.

private void dg_MouseUp( object sender, System.Windows.Forms.MouseEventArgs e )
{
      dg.Select(dg.CurrentRowIndex);
}

2. The solution for getting the row to select when the user navigates using the arrow keys.

private void dg_CurrentCellChanged( object sender, System.EventArgs e )
{
      dg.Select(dg.CurrentRowIndex);
}

I tried this on a .NETCF Pocket PC app and it worked great. Also, it solved one of the issues that I had to solve, easily.