Monday, July 07, 2008 #

ScriptControl question

As of late I have gotten a chance to use the ASP.Net AJAX extenders and script controls, and so far am really liking how they work, though it would be nice if adding the .js was a little cleaner then manually adding them to the assembly wether in the AssemblyInfo.cs or the controls cs file.

I have to say I really like the extender and script controls that come with the ASP.NET AJAX. They really are so much nicer to work with then building up Javascript strings in the CS file of the server control.

I do have a question about them though. One of the ScriptControls I made uses a webservice to pull data if the service name is set. At the moment I have it dynamically registering an JSON script service based webservice. Unfortunately I have found that this is not an optimal solution since the name of the Javascript object created by the ScriptService changes depending on the namespace and class name of the service.

I am sure that there is a better way to do this, but I am not exactly certain of it. Any suggestions or links would be appreciated.

posted @ Monday, July 07, 2008 4:09 PM | Feedback (0)

Wednesday, May 21, 2008 #

Lazy list

I have been following Rob Conery's posts on the MVC Storefront, and trying the repository/pipes-filters for data access that he has been using.

While trying out the implementation of a LazyList he was using, I had noticed that the example table was being joined onto the category table. At the time however, I really had not thought much of it, until I read MVC Storefront: Brainbender Intermission which got me thinking.

Admittedly, I don't really have to much of a problem with it loading all of the examples for all the categories at one time at the moment. However, I figured it would be nice to have it work the way intended, and query the database for the examples in a category only when asked for.

I liked the idea of the LazyList, and since I was already using a Service class for all data access, along with setting up the category hierarchy I moved the creation of the LazyList of examples property into the the GetCategories method of the service class.

It seems that as long as the LazyList is created after the categories .ToList() call it properly works. So I ended up with this code:

            categories.ForEach(category =>
            {
                category.Examples =
                    new LazyList
                        <DevExamples.Data.Example>(
                        from e in repository.GetExamples()
                        where e.CategoryId == category.ID
                        select e);

                var subCategories = (from sub in categories
                                     where sub.ParentId == category.ID
                                     select sub).ToList();
                category.SubCategories = subCategories;

                subCategories.ForEach(c => c.Parent = category);

            });

 

Technorati Tags:

posted @ Wednesday, May 21, 2008 12:34 AM | Feedback (0)

Thursday, September 20, 2007 #

Custom Rss Admin feeds

I fixed up the Rss Admin feeds so that modifying web.config (along with new handler classes) would not needed to add a new Admin Rss feed.

Also added a simple form to allow administrators to created their own. It is a bit limited, but adding additional options should not be to hard. Though those will have to wait till a later date.

On a side note, I found that if I had the option of returning the non-generic  base class, or a generic subclass it makes the code a lot more flexible if you return the non-generic base class if you do not have a need to have the generic type.

 

 

Technorati Tags:

posted @ Sunday, April 20, 2008 6:34 PM | Feedback (0)

Sunday, April 20, 2008 #

The joys of spam

I woke up this morning to 600+ bounce messages in my inbox. And over the course of the day probably another 600+.

Apparently someone decided that it would be fun to send a spam message around 11:40 last night using my email address.

Hopefully this was a one time thing. So I don't have to try to figure out where all I need to change this email address at.

posted @ Sunday, April 20, 2008 5:11 PM | Feedback (0)

Monday, March 17, 2008 #

.Net based SVN client library

As an exercise to figure out socket programming I have been messing around with creating an SVN client library to use with DevExamples.com, well actually a generic SC client library that would allow me to change what repository site I was working against, SVN just seemed like the simplest of them at the moment.

However, after thinking about it, I think it would be better to use one that is already built if possible. I just have not been able to find a pure .Net client library. It is also seems rare for a source control library to work without a working folder, which is somewhat limiting when I want to check the propagation of examples using this method on the same machine.

Though I think it would be interesting to write a LINQ to Source provider, as a way to learn expression trees better. Plus it would be nice to be able to not only easily switch hosting providers (the reason I am looking for a pure .Net library) but also to have a standard syntax to allow me to easily switch from SVN to SourceGear's Vault (which I use for my personal development projects) to TFS (which we use at work) as the storage system for the examples.

Though SvnBridge could possibly help with that too.

Technorati Tags: ,,,

posted @ Monday, March 17, 2008 11:29 PM | Feedback (2)

A few simple MVC control suggestions

I finally got around to updating the website to the MVC preview 2, and ran into a couple of things.

  1. TagBuilder being internal. While the implementation of it CreateInputTag, CreateTag and CreateAttributeList. The removal of .ToAttributeList() was actually what made me go looking for this. The HtmlExtensionUtility extension methods would have been nice to have also.

    I guess a better way to say it is it would be nice not to have to reimplement the functionality that CreateAttributeList and ConvertObjectToAttributeList already implement.
  2. It would be nice if SimpleForm inherited from a class, that could be subclassed to make Div and Span tags that have attributes based on routing information.

    Admittedly it is a rather simple to implement what I am talking about but I think it would be nice to have already there.

 

I'm still rummaging through the routing stuff, so don't have to much input on those it at the moment. But it looks like I will be able to take all the category discovery information out of my controllers, and just have it passed into the action, which will be nice.

On a side note, after looking at the classes that were made into base classes. I cant really say that I would ever have a need for them to be interfaces. As I can't think of any other class I would want to tack their functionality onto, after all interfaces were the answer to not having multiple inheritance (I still wish I had it multi-inheritance though).

I do however hope that IRouteHandler stays an interface though, because I can see myself taking that behavior onto an object. Just not sure where.

Technorati Tags:

posted @ Monday, March 17, 2008 10:49 PM | Feedback (0)

Tuesday, February 05, 2008 #

I figured out what I was missing

I figured out what I was missing in I think I'm missing something. It was using ".Join" instead of ".Where".

And it turns out that it is a much cleaner implementation then I had done in Got my nice Urls working. So here it is.

var cats = this.Categories.Where(c => c.Name == navList.First().Value);
foreach (var item in navList.Skip(1))
{
    string name = item.Value;
    cats = cats.Join(this.Categories.Where(c => c.Name == name)
        ,c=>c.Key,c=>c.ParentKey.Value,(c,p)=>p);
} 
cat = cats.First();

Which generates the correct Sql bellow

image 

Edit:
Does anyone know if there is a book for LINQ (to SQL in particular) that would be equivilent to Essential Windows Workflow Foundation, that explains how they ended up with the solution they did?

Technorati Tags:

posted @ Tuesday, February 05, 2008 11:02 PM | Feedback (1)

IIS 7.0 hosting

I am curious if anyone could recommend a hosting company that is running, or has announce when they will be, IIS7 servers now that it is released.

I have looked around MaximumASP's site and have yet to find anything regarding a timeframe. Plus I am finding that several smaller shared hosting sites will fill my needs as well as a dedicated or virtual dedicated server does, for a decent amount less.

Preferably, they would not charge a per domain pointer fee.

posted @ Tuesday, February 05, 2008 10:39 PM | Feedback (0)

I think I'm missing something

I finally found time to work on DevExamples.com again and thought I would check on the suggestion that Richard had left on Got my nice Urls working about using incremental LINQ.

Overall I found that I liked the following syntax much better

 var cats = this.Categories.Where(c => c.Name == navList.First().Value);
 foreach (var item in navList.Skip(1))
 {
  string name = item.Value;
  cats = cats.Where(c => c.Name == name);
 } 
 cat = cats.First();

Unfortunately this only works for the first parent in the hierarchy. After the first parent, it continues to simply work off of the single join. The problem is that instead of generating

image

it is generating

image

I think I understand why I am getting this result, though it was not what I was hoping.

In the end I think I will stick with how I implemented it in Got my nice Urls working until I either think of, or run into, a way to do it with lambda expression. Plus I like the Sql  generated in the previous post a little better mostly for trace readability.

image

Technorati Tags:

posted @ Tuesday, February 05, 2008 10:30 PM | Feedback (1)

Friday, January 04, 2008 #

Being blocked by internal/private

I ran into a situation that reminded me of Steam Harman's post about A New Year's Resolution for Developers in which he states that by default methods should be public and virtual unless there is a good reason not to.

This started when after I decided I was missing functionality like RegisterClientScriptBlock, allowing me to add a client script only if one of the controls needs it, along with only adding it once. I was also missing the ability to use designers.

To this end, I decided I was going to make a simple server control library with server controls that would provide the functionality found in the MVCToolkit Html extension methods. I also figured it would be nice if I could allow them to function in WebForms as well, if they are on a runat server form tag.

After a while I found the VerifyRenderingInServerForm method on the Page, which seemed to be the only method available for this. Unfortunately while I can override this method after loading up reflector to see how the base Page was determining that the control is in a form tag, I found that I could only do it with a try/catch around base.VerifyRenderingInServerForm.

While I don't really have much of a problem doing this, there is a little bit of nagging in the back of my head over the fact that the Page class contains a method called IsInOnFormRender, which has exactly the information I want. Unfortunately this property is internal, preventing me from retrieving efficiently retrieving this information.

The other problem I find with this is that these server controls would need to run on a special page in order to have the desired functionality, have each of the controls that while have the functionality do the try/catch on VerifyRenderingInServerForm, or use reflection to get access to that variable. None of which are particularly optimal.

On a side note, I wish I had found this method when I years ago when I was writing the controls of the framework we use at work. Since I could not have our controls running within a runat server form tag because we submit the data through an IFrame, overriding VerifyRenderingInServerForm would have allowed me to stop them from throwing the error.

Technorati Tags: ,

posted @ Friday, January 04, 2008 12:48 AM | Feedback (0)

Copyright © Sean Lynch

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski