Redirecting using strong types in an asp.net web application project

January 13, 2010

It recently began to annoy me that every time I want to redirect to a page I have to use a string. Not a big deal I know but when you have broken links it can reflect badly on you as a developer, so I began to look for some solution that would allow for the following.

  • Refactoring: I need to be able to move a page around without having to find every string reference to it
  • No Reflection: It’s slow I don’t want to have to use it when redirects happen often.
  • Parameters: I want to be able to pass parameters to a function and make that become part of the get request, I want the logic for that to exist on the page being redirected to as that is where the parameters are being used, this will also help with refactoring, the plain ole redirect logic however would just exist on a base class, don’t want to have to rewrite for every page.

I knew the ideal situation would be if I could somehow use the fact that web application projects use the folder hierarchy for its namespace convention and end up being able to redirect to the page ~/Users/UserDetails.aspx?UserId=14 with the following command Users.UserDetails.Redirect(14);

Here is how I did it: Continue Reading »

  • Share/Bookmark

Why Google Wave is a Big Deal

November 29, 2009

I’ve been using the alpha version of google wave for about a month and a half, and I have to say that I’m a fan. This post is mostly about saying why I’m a fan and also why I think that google wave is going to change the way we communicate through text.

The reason I’m writing this post is because there are a lot of people who have heard bits about it or just haven’t spent the time using it and really can’t see  why this is such a big deal. Hopefully this post will go some way towards convincing you of it’s merit, but feel free to add your own insights in as comments.

Google Wave has been described by Google as what email would look like had it been designed in the 21st century.  Wave is standing on the shoulders of giants, it reflects the evolution of internet communication by bringing together mature concepts as the principals or requirements of their system and uses new technology to hold it all together. It’s worth keeping this in mind when you think about the future of Google Wave. It may be new, but there is so much to this that we’ve seen before. My first reaction on using Google Wave was, “Is that it?”.  The real shocker was when after a short time using Google Wave I was coming back to my trusty MSN messenger and finding it unpleasant to use.

Continue Reading »

  • Share/Bookmark

Custom Control won’t trigger Update Panel

November 24, 2009

I was using the __dopostback  function in asp.net to cause a postback that would trigger an update in an updatepanel where relevant.

If you come across this problem make sure that your custom control implements the INamingContainer as well as the IPostBackEventHandler interfaces

Also make sure that your first argument to the __dopostback function is the unique id of your custom control (this.UniqueId)

  • Share/Bookmark

How to Mock the HttpContext in asp.net

October 13, 2009

I find mocking the http context rather difficult, you can’t inherit from it and making a wrapper class is a lot of work. Thankfully someone came up with a solution, unfortunately the link they included with the code is dead and I can’t seem to remember where I got the code, if anyone finds out where it comes from please comment and I’ll add it to the post.

Continue Reading »

  • Share/Bookmark

JqGrid.Net Public Beta

September 16, 2009

Just started using the ASP.Net Web Forms wrapper for JqGrid, worth taking  a look at

http://trirand.net/default.aspx

  • Share/Bookmark

Official JqGrid ASP.Net Web Forms Control Alpha Demo

September 10, 2009

First look at the official JqGrid ASP.Net Web Forms control here http://www.trirand.net/jqgrid.aspx

Includes support for Linq and object data sources.

  • Share/Bookmark

Improve your testing

September 10, 2009

The Art of Unit Testing

Last night I was at the first meeting of the local alt.net book club, we’re currently going through a book called the art of unit testing. What I took from reading the first chapter and the discussion we had at the meeting was that you test your code already, your tests can be improved and unit testing will improve it. My first mistake was to confuse what unit testing was. I thought it was just automated testing. I had used a unit testing framework and that’s all that I had learnt from doing so. However once you start reading up on the best practices of testing you hear a different story.

Continue Reading »

  • Share/Bookmark

Strong Name an existing dll or assembly

September 8, 2009

Taken from http://sadeveloper.net/forums/p/1195/5115.aspx
Saved me a lot of hassle

We’ve got a 3rd party DLL that we use (not strong named) and I wanted to add it to the GAC. Alas! Only strong named assemblies are allowed in the GAC.

I’ve been trying figure this out for almost a week… couldn’t find much help on Google , so I thought I’d share.

Well, here is my solution (it works… not sure if it’s the best way though)

From a VS.NET command prompt, enter the following:

1. Generate a KeyFile

sn -k keyPair.snk

2. Obtain the MSIL for the provided assembly

ildasm providedAssembly.dll /out:providedAssembly.il

3. Rename/move the original assembly

ren providedAssembly.dll providedAssembly.dll.orig

4. Create a new assembly from the MSIL output and your assembly KeyFile

ilasm providedAssembly.il /dll /key= keyPair.snk

Viola!

You now have a strong named assembly.

  • Share/Bookmark

o2: Paying more than you intended

August 30, 2009

I was reading the register recently, it had said that under new EU law roaming now had capped prices. I may have misread it, I can’t find the article, but I believed it said that data roaming charges within the EU are also capped at 1 euro per MB. As someone who has been bitten in a small way by that before I rejoiced and when I went to france I downloaded a whole 25 MBs (using google maps, downloading email). For this I was charged 120 euro (ex vat). I called up o2 and they told me that the cap was limited to calls and texts. I’m on a bit of a tight budget at the moment due to having to pay off a loan from college and I don’t know about you but 120 euro, certainly completely unplanned is a lot of money. Especially when added on to the fact that I had just had a 5 day holiday that I’m still paying for.
This is designed to make you spend more money than you intended.

Continue Reading »

  • Share/Bookmark

Calendar Extender arrows in IE8 bug

August 25, 2009
.ajax__calendar_title
{width:150px; margin:auto; padding:3px;}

Taken from here: http://forums.asp.net/p/1395899/3000757.aspx

If you are finding that you can’t click on the arrows on the Calendar Extender in IE 8 try using the following css.

.ajax__calendar_title{width:150px; margin:auto; padding:3px;}

It stops the calendar title from extending over the arrows.

  • Share/Bookmark
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org