August 2006 - Posts - Derek Adkins

August 2006 - Posts

Response.redirect with a target attribute

I have a problem that Googling is not solving. Maybe someone can help out with this:

I want to redirect to an external site from my ASP.NET application but with a target=_blank attribute.

I also want to dynamically add querystring parameters to the URL in codebehind before doing the redirect.

Is this possible?  I've seen some JavaScript that only works for static URL's.  I want to append session variable values onto the end of the URL in codebehind before redirecting.

Any ideas?

Some masterpage tricks...

I've been redesigning our corporate site to use master and detail pages, and there were a few things that I was battling to get right.

Firstly, in design view for the master page, it doesn't recognise the theme style sheet, so it's quite a pain to visually align controls without the theme being visible.... UNTIL... I realised that you can add the following to the master tag at the top of the master page:  StyleSheetTheme="<themename>" , and it shows fine in design view.  It won't compile until you remove it again, but at least you can view the master page in design view with the theme applied.

Secondly, I was wondering how to interact with controls on the masterpage from the child pages.  And I found this excellent article that explains how to expose properties on the master page and interact with them from child pages.  Link:  http://www.odetocode.com/Articles/450.aspx

Testing from Windows Live Writer

I've just downloaded and installed Windows Live Writer, and I'm hoping this works.

One thing though, I took all the options from the install program, and I have this HUGE toolbar in IE7 now.  I'm certain that half of this stuff will never be used.

Personally, as a general rule, Toolbars are bad. :)

Multitouch Computer Screen

http://tech.cybernetnews.com/2006/08/06/revolutionary-multi-touch-computer-screen

Watch the video. Be blown away!

Disappearing cache problem.

Maybe someone can help me with this:

I have a set of Net 2 webservices running in IIS that store login information in HttpContext.Current.Cache.

Now the problem I have is that it works fine to retrieve the information between webservice calls, but sometimes, without doing anything more than stop debugging and restart, I get "Object reference not set to an instance of an object" error when trying to access the cache object.

I store the username and password from the "login" webservice in the cache with a GUID as the key.  Then subsequent webservice calls pass in the GUID, and fetch the username and password from the cache.

Public Class CacheStruct

Public userName As String

Public Class CacheStruct

Public userName As String

Public userName As String

Public password As String

Public password As String

End Class

End Class

Public Shared Sub Add(ByVal userName As String, ByVal password As String, ByVal sid As String)

Dim userObj As New CacheStruct

userObj.userName = userName

userObj.password = password

HttpContext.Current.Cache.Add(sid.ToString, userObj, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)

End Sub

Public Shared Sub Add(ByVal userName As String, ByVal password As String, ByVal sid As String)

Dim userObj As New CacheStruct

userObj.userName = userName

userObj.password = password

HttpContext.Current.Cache.Add(sid.ToString, userObj, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)

End Sub

Dim userObj As New CacheStruct

userObj.userName = userName

userObj.password = password

HttpContext.Current.Cache.Add(sid.ToString, userObj, Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)

End Sub

Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), Caching.CacheItemPriority.Normal, Nothing)

End Sub

End Sub

Public Shared Function Lookup(ByVal sid As String) As CacheStruct

Return CType(HttpContext.Current.Cache.Get(sid), CacheStruct)

End Function

Public Shared Function Lookup(ByVal sid As String) As CacheStruct

Return CType(HttpContext.Current.Cache.Get(sid), CacheStruct)

End Function

Return CType(HttpContext.Current.Cache.Get(sid), CacheStruct)

End Function

End Function

Is the GC cleaning up that cache object somehow?  Is IIS resetting somehow?

Project analogy

Project Manager is a Person who thinks nine women can deliver a baby in One month.

Developer
is a Person who thinks it will take 18 months to deliver a Baby.

Onsite Coordinator
is one who thinks single woman can deliver nine babies in one month.

Client
is the one who doesnt know why he wants a baby.

Marketing Manager
is a person who thinks he can deliver a baby even if no man and woman are available.

Resource Optimization Team
thinks they dont need a man or woman; theyll produce a child with zero resources.

Documentation Team
thinks they dont care whether the child is delivered, theyll just document 9 months.

Quality Auditor
is the person who is never happy with the PROCESS to produce a baby.

System
Tester is a person who always tells his wife that this is not the Right baby.