Social Networks and I

by Pascal Parent 3. June 2009 16:01

I feel the need to clarify my stance towards Social Networks, I hate them, really I do. But in this day and age if you are not on Facebook, LinkedIn and something like Digg or Technocrati you are no one. I do believe in blogs and by the nature of it Twitter, neither are “blocked” to a subscription system of sorts, so to me it is far friendlier, I only login to Facebook and LinkedIn when I get a mail telling me there are messages.

So you may ask how are my Facebook and LinkedIn accounts so active, its bacause both of my accounts are linked to both my Blogs RSS, Twitter and Flickr accounts and that is my kung-fu.

I update Twitter with TweetDeck and my websites with Windows Live Writer, both are stable and now Tweedeck also pulls info from Facebook, check them out.

Unfortunately “Social Networks” are a necessary evil in my life, so I live with it.

Cross-posted from Only in South Africa .COM

Tags:

General

JQuery Validate plugin to validate a ASP.NET Form

by Pascal Parent 25. May 2009 09:30

The first time I used the JQuery Validate plugin, it did not work at all, see JQuery Validate odd behaviour with the ASP.NET Script Manager for reason, but perseverance and stubbornness prevailed and I finally created my first JQuery validated ASP.NET Forms contact form. There are a lot of examples out there, though for some odd reason I can never find a decent example of anything to do with ASP.NET Forms and JQuery, so I battled it out.

First and foremost, when using JQuery with forms the this.object.ClientID function is your second best friend, your best friend is the fact that you can have more than one CSS class descriptor in one class, for example the following CssClass="required email" is completely valid, thanks to JQuery’s CSS Selector. This means the you do not have to know the object’s name and that the same behaviour can easely be set to more than one object with ease.

But I digress, though I must be honest I am still learning a lot about JQuery’s ability to make my life easier every day.

The initiation code is simple enough:

<asp:ScriptManager ID="ScriptManagerProxy1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Assets/Javascript/jquery.validate.pack.js" />
     </Scripts>
</asp:ScriptManager>
<script language="javascript" type="text/javascript">
     $(document).ready(function() {
$('.error').hide();
$('#<%= this.Page.Form.ClientID %>').validate();
});
</script>

A few things worth noticing, I use the ScriptManager for relative path (the ~/ thing), this eases the problems related to maintenance and moving the ASP.NET file will cause no adverse effect, so if like me you want to refactor the path, it’s not an issue. I also hide all error text $('.error').hide() it is recommended to hide any object wit the .error Css selector prior to use. And then register the validation methods where I use this.object.ClientID to ensure that the right object is called, since I make use of MasterPages this is essential.

From here things get even easier, apply the required validation on the object

<asp:TextBox ID="txtEmail" runat="server" CssClass="required email"></asp:TextBox>

Though not required, I would advise that, as a standard, the first CSS selector have an actual class in the CSS file. I also set a default class to all of my inputs.

For further built-in and custom validation requirement please head over to JQuery Validate plugin page where you will find the documentation.

Tags: ,

ASP.NET

JQuery Validate odd behaviour with the ASP.NET Script Manager

by Pascal Parent 24. May 2009 13:06

I discovered the JQuery Validate plugin a while back and could never get it to work in ASP.NET until today and though I have no idea why this the code bellow does not work.

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <CompositeScript>
        <Scripts>
            <asp:ScriptReference Path="~/Assets/Javascript/jquery.validate.pack.js" />
        </Scripts>
    </CompositeScript>
</asp:ScriptManagerProxy>

If the extension is in the <CompositeScript> section it does not work, I will try to figure out why later but if it is removed from the <CompositeScript> it start to work again.

So the resultant code will look like this:

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <Scripts>
       <asp:ScriptReference Path="~/Assets/Javascript/jquery.validate.pack.js" />
    </Scripts>
</asp:ScriptManagerProxy>
I honestly say that the JQuery Validate plugin is the best validation package I have come across in a while, go and get it.

Tags: ,

General

Typemock Is Launching The ASP.NET Bundle – Get Free Licenses

by Pascal Parent 19. May 2009 06:59

Unit Testing ASP.NET? ASP.NET unit testing has never been this easy.

Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out FREE licenses to bloggers and their readers.

The ASP.NET Bundle is the ultimate ASP.NET unit testing solution, and offers both Typemock Isolator, a unit test tool and Ivonna, the Isolator add-on for ASP.NET unit testing, for a bargain price.

Typemock Isolator is a leading .NET unit testing tool (C# and VB.NET) for many ‘hard to test’ technologies such as SharePoint, ASP.NET, MVC, WCF, WPF, Silverlight and more. Note that for unit testing Silverlight there is an open source Isolator add-on called SilverUnit.

The first 60 bloggers who will blog this text in their blog and tell us about it, will get a Free Isolator ASP.NET Bundle license (Typemock Isolator + Ivonna). If you post this in an ASP.NET dedicated blog, you'll get a license automatically (even if more than 60 submit) during the first week of this announcement.

Also 8 bloggers will get an additional 2 licenses (each) to give away to their readers / friends.

Go ahead, click the following link for more information on how to get your free license.

Tags:

General

Forthcoming trip

by Pascal Parent 1. May 2009 15:01

I am going on a trip to discover and rediscover some places and take some great photos I hope. So fro the next 2 weeks this blog is going to be rather quiet.

But head out to by other blog “Only in South Africa” from the 3rd of where I will try to do one post a day on the places I have been to.

You can also check my Flickr account as well as I will be posting the photos there.

Tags:

General

Weird ADO.NET Entity Framework behaviour

by Pascal Parent 17. April 2009 13:53

I started my project using a Microsoft SQL 2008 server and the ADO.NET Entity Framework only to find out that the host does not support Microsoft SQL 2008 server but only supports Microsoft SQL 2005 server.

Generally, I would just port the database and change the connection string… Which is what I did!

EF was not happy about that because EF still thought it was a SQL 2008 server and built it’s T-SQL accordingly, which failed because it used new commands. This was fine with me, until I realised to my surprise that I could not find any settings to change EF’s SQL version, I searched the code, the config files,...

A Google search did not return any valuable information either.

Though I found a solution, whether or not it is the best. Refresh the mapping file, rebuild the project and voila everything works again.

I find it odd though, I wander what would happen if I had switched to MySQL or Oracle.

Tags: , ,

ASP.NET | Database

Linq limitations

by Pascal Parent 12. April 2009 18:46

I am currently writing a small website for one of my companies clients and decided that I should use LINQ-to-Entities and the ADO.NET Entities Framework to make my life easier and to learn a bit more about LINQ. You may recall a statement I did a few months ago on Twitter “ADO.NET Entity Framework sucks! Linq Rocks!” well I stand by that but it has some serious shortcomings, I would call it a bug but then it would be a documented bug. You cannot use any Entity.Field.ToString in a Linq block!

So the following code will fail:

using (Entities db = new Entities())
{
    var news = (
                   (
                       from N in db.NewsSet
                       where N.PublishedDate <= DateTime.Now
                       orderby N.PublishedDate descending
                       select new
                       {
                           Date = N.PublishedDate.ToString("dddd, dd MMMM yyyy"),
                           Headline = N.Headline,
                           Article = N.Content,
                           Author = N.Author,
                       })
                   ).First();

    this.litHeadline.Text = news.Headline.Trim();
    this.lblDate.Text = news.Date.Trim();
    this.litArticle.Text = news.Article.Trim();

}

The error is: System.NotSupportedException: LINQ to Entities does not recognize the method 'System.String ToString(System.String)' method, and this method cannot be translated into a store expression.

The line that will fail is Date = N.PublishedDate.ToString("dddd, dd MMMM yyyy") because I use ToString, which in my opinion is ridiculous. Why can I not format or manipulate the variable as I wish? Microsoft, please fix this or remove the Intellisence that allows me to do that. See be llow.

Linq.ToString

The actual code that works is here bellow:

using (Entities db = new Entities())
{
    var news = (
                   (
                       from N in db.NewsSet
                       where N.PublishedDate <= DateTime.Now
                       orderby N.PublishedDate descending
                       select new
                       {
                           Date = N.PublishedDate,
                           Headline = N.Headline,
                           Article = N.Content,
                           Author = N.Author,
                       })
                   ).First();

    this.litHeadline.Text = news.Headline.Trim();
    this.lblDate.Text = news.Date.ToString("dddd, dd MMMM yyyy");
    this.litArticle.Text = news.Article.Trim();

}

For more information Muhammad Mosa has a good article called Linq to Entities, what is not supported? I highly recommend that you read it along with Microsoft’s MSDN Supported and Unsupported Methods (Linq to Entities) 

Next Dynamic Linq…

Tags:

General

The ASP.NET Guy goes live

by Pascal Parent 3. April 2009 14:40

It’s official my new ASP.NET and .NET site is live at http://www.theaspnetguy.com and it was not an easy task.

I had to export the entries from Wordpress, clean the data, import it into BlogEngine.NET clean the entries and voila a bran new blog! And a lot of work to come. And finally, I removed all development entries from Only in South Africa.

I needed it up because I am busy on an ASP.NET 3.5 SP1 project which will make extensive use of the dreaded ADO.NET Entity Framework and the lovable Linq to Entities.

Long live The ASP.NET Guy!

Cross posted from my personal blog Only in South Africa

Tags:

General

Welcome to BlogEngine.NET 1.5.0

by Pascal Parent 2. April 2009 09:00

If you see this post it means that BlogEngine.NET 1.5.0 is running and the hard part of creating your own blog is done. There is only a few things left to do.

Write Permissions

To be able to log in to the blog and writing posts, you need to enable write permissions on the App_Data folder. If you’re blog is hosted at a hosting provider, you can either log into your account’s admin page or call the support. You need write permissions on the App_Data folder because all posts, comments, and blog attachments are saved as XML files and placed in the App_Data folder. 

If you wish to use a database to to store your blog data, we still encourage you to enable this write access for an images you may wish to store for your blog posts.  If you are interested in using Microsoft SQL Server, MySQL, VistaDB, or other databases, please see the BlogEngine wiki to get started.

Security

When you've got write permissions to the App_Data folder, you need to change the username and password. Find the sign-in link located either at the bottom or top of the page depending on your current theme and click it. Now enter "admin" in both the username and password fields and click the button. You will now see an admin menu appear. It has a link to the "Users" admin page. From there you can change the username and password.  Passwords are hashed by default so if you lose your password, please see the BlogEngine wiki for information on recovery.

Configuration and Profile

Now that you have your blog secured, take a look through the settings and give your new blog a title.  BlogEngine.NET 1.4 is set up to take full advantage of of many semantic formats and technologies such as FOAF, SIOC and APML. It means that the content stored in your BlogEngine.NET installation will be fully portable and auto-discoverable.  Be sure to fill in your author profile to take better advantage of this.

Themes and Widgets

One last thing to consider is customizing the look of your blog.  We have a few themes available right out of the box including two fully setup to use our new widget framework.  The widget framework allows drop and drag placement on your side bar as well as editing and configuration right in the widget while you are logged in.  Be sure to check out our home page for more theme choices and downloadable widgets to add to your blog.

On the web

You can find BlogEngine.NET on the official website. Here you'll find tutorials, documentation, tips and tricks and much more. The ongoing development of BlogEngine.NET can be followed at CodePlex where the daily builds will be published for anyone to download.

Good luck and happy writing.

The BlogEngine.NET team

Tags: ,

BlogEngine.NET

Bandwidth in South Africa - Part 2 - Usage

by Pascal Parent 17. March 2009 03:03

In Bandwidth in South Africa – Part 1 – Cost I discussed the cost implications of the consumer internet and as we saw it did not come cheap. In this part I will be discussing the usage trends. It took awhile to get the statistics and I can safely say that they represent a reality that I was not ready for, see Number of Users bellow.

Connectivity_Number_of_Users
74% of the South African users are still using dialup! And a further 24% uses ADSL 384, I unfortunately could not get the 3G, Neotel and Fixed Line usage at the time of writing. Now let us move to ADSL CAP usage.

ADSL_CAP_Usage
46% of the users use 1GB or less, no doubt due to the costs involved. I was troubled by those statistics and enquired further to no avail.

The point I am trying to make with these statistics is two fold:

  1. The challenges of writing web application in an environment such as this goes far beyond just writing code to get the site to work but adds a dimension of careful optimisation of traffic between the browser and the server in all respects caused by both the speed and cap of the link.
  2. Is this symptomatic or can this be fixed by the landing of new cables in South Africa, will bandwidth and cap prices go down to a reasonable and reachable price? Our friends at mybroadband.co.za think so. I am sceptical and will stick with the my first statement, optimise!

Tags: ,

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010 The ASP.NET Guy