Binary Artist

The Jason Marshall Experience

Binary Artist

Jason Marshall
E-mail me Send mail

Recent comments

Authors

Disclaimer

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

© Copyright 2010

ASP.NET MVC 2 DropDown

Html.DropDownFor Alternative:

<
select>
<%
foreach (var Order in Model.Orders)
{
%>
<option value="<%: Order.Id%>"><%: Order.OrderName%></option>
<%
}
%>
</select>


Categories: Pool
Posted by Admin on Tuesday, June 01, 2010 8:49 AM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET MVC Html.TextBoxFor custom htmlAttributes

This is the easiest way to add or change the attributes of  TextBoxFor Html helper.
I was attempting to change the type from "text" to "email" so the IPhone would detect this field as an email adress.

 

<%: Html.TextBoxFor(model => Model.Genres, new { @Type="email" }) %>


Posted by Admin on Friday, May 28, 2010 9:17 AM
Permalink | Comments (0) | Post RSSRSS comment feed

APS.NET MVC (Part 1) The Model, View and Controller

 

And so it begins.  My epic journey into the Microsoft Model View Controller.  This is not new technology,  other languages (see Ruby on rails) have used this model for a while,  and now Microsoft has adopted it in the new ASP.NET 4.0 Frame work.

  • Model: The model contains the core information for an application. This includes the data and validation rules as well as data access and aggregation logic.
  • View: The view encapsulates the presentation of the application, and in ASP.NET this is typically the HTML markup.
  • Controller: The controller contains the control-flow logic. It interacts with the Model and Views to control the flow of information and execution of the application.  A controller should contain only logic related to application flow control.
  • Browser sends a request Controller. 
    The Controller the processes the URL request. 
    Control is then sent to the Model, asks the model for information probably from a database.
    Once the Model has finished it's work it sends control back to the Controller. 
    The Controller can then go back to the Model if it needs to, doing as much work as it needs before it finally renders the View.
    The view is contructed using the data passed from the Model by the controller back to the User.


    Tags: ,
    Categories: MVC
    Posted by Admin on Thursday, May 20, 2010 10:10 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Simple jquery value in and value out of a textbox

     jquery value in and value out

      $('#ControlID').val(“This is the string to set”); 

    alert($('#ControlID').val());   

    C#  CodeControl1.Text = Control2.Text;  

    jquery Equivlent$('#ControlID1').val($('#ControlID2').val())); 


    Tags: , ,
    Categories: C# | jquery
    Posted by Admin on Thursday, May 07, 2009 12:41 PM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Top 20 Movies of all time

    1.  Apocalypse now
    2.  Reservoir Dogs
    3.  pulp fiction
    4.  The Godfather
    5.  The Matrix
    6.  Slumdog Millionaire
    7.  The Pianist
    8.  Saving Private Ryan
    9.  Schindler's List
    10. Shawshank Redemption
    11. Alien
    12. Million Dollar Baby
    13. The Boondock Saints
    14. Forrest Gump
    15. Full metal Jacket
    16. Rocky
    17. Raiders of the lost Ark
    18. Terminator
    19. American History X
    20. Jaws

    Categories: Movies
    Posted by Admin on Tuesday, February 03, 2009 10:48 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Iterate through Struct Constants using reflection

     

    using System.Reflection;
     

    public Hashtable searchHash = new Hashtable();
    System.Reflection.FieldInfo[] fields = [myStructName].GetType().GetFields();
    foreach (System.Reflection.FieldInfo field in fields)
    {
    searchHash.Add(field.GetValue([myStructName]).ToString(),
    "|");
    }


    Posted by Admin on Monday, July 14, 2008 6:18 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Book Review: Domain-Driven Design: Tackling Complexity in the Heart of Software

    Great book by Eric Evens discussing the domain driven approach to software design.

    Finishing up this book...a book review will be comming soon...

     

    "There are many things that make software development complex. But the heart of this complexity
    is the essential intricacy of the problem domain itself. If you're trying to add automation to
    complicated human enterprise, then your software cannot dodge this complexity—all it can do is
    control it."

    "The key to controlling complexity is a good domain model, a model that goes beyond a surface
    vision of a domain by introducing an underlying structure, which gives the software developers the
    leverage they need. A good domain model can be incredibly valuable, but it's not something that's
    easy to make. Few people can do it well, and it's very hard to teach."


    Tags: , ,
    Categories: C# | LINQ | SQL Server | XNA | Domain Driven
    Posted by Admin on Wednesday, May 14, 2008 8:00 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    SOA Using WCF proxy Inside SQL SSIS with a CAG'ed dll.

    What does all that nerd lingo mean?

    Basically I have some data I need to take out of the database and pass it to another server for processing in a service oriented architecture.
    When this remote process is complete it will pass me back the results that I will save in the database.
    The transport mechanism we will use is WCF or windows communication foundation.  To use this on the client side, which happens to be a database process. We will create a proxy class.
    SQL SSIS is SQL Server's new DTS on steroids performance enhanced DTS. SSIS allows scripting in VB.net only (don't ask), and to use outside compiled dll's you have to register them in the Global Assembly Cache with a strong name, this is just a fancy way of making sure your dll's are unique.

    This will happen on a timed interval.  Seams pretty simple huh?

    In order to leverage windows communication foundation within SQL Server SSIS there are a number of things you have to do to make this happen. 


    Build your client proxy WCF service model bindings from WCF service.

    1. Build an assembly that will wrap the logic for your WCF call.
    2. Sign the assembly with a strong name. (sn.exe or VS IDE).
    3. GAC your new assembly on the SQL box by copying into C:\WINDOWS\assembly.
    4. Merge your proxy app settings into DtsDebugHost.exe.config and DTExec.exe.config.
    5. Welding in custom assemblies in SSIS with configuration variables.

     

     

     Make sure your dll is GAC'ed and refernced in your SSIS script project.

     Make sure your dll is added to your Package.dtsx.

     


    Tags: , ,
    Categories: C# | GAC | SQL Server | SSIS | WCF
    Posted by Admin on Wednesday, May 14, 2008 6:48 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Sharing WCF Collection Types between Service and Client

    This particular feature will get ya ! if your not aware of it.

     

    When using the SvcUtil.exe and specifying shared collectionTypes;

    The expression in the collectionType switch for a shared collection is followed by a back quote (`) and a 1.
    For generic types, you must specify the number of generic parameters with a back quote followed by the number of generic parameters.
    Do not confuse the back quote (`) with the single quote (').

    "c:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SvcUtil"
          /language:cs
          /out:ServiceClient.cs 
          /namespace:*,ShareTypes.Client
          /noconfig
          /reference:..\ShareTypes.Common1\bin\Debug\ShareTypes.Common1.dll
          /reference:..\ShareTypes.Common2\bin\Debug\ShareTypes.Common2.dll
          /collectionType:ShareTypes.Common.SharedCollection1
          /collectionType:ShareTypes.Common.SharedCollection2`1
          net.tcp://localhost:9042/Service/mex

    Great article here on this topic...

    http://www.codeproject.com/KB/WCF/WCFCollectionTypeSharing.aspx


    Posted by Admin on Thursday, May 08, 2008 10:27 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    The project location is not trusted

     

    If you download zipped up Visual Studio project files and extract them with out Unblocking the zip file first, you will get an error.

    Right click on the zip and Unblock -> press apply before extracting.

    Speaking of untrusted zones ....


    Posted by Admin on Thursday, May 08, 2008 5:03 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Jump off the stack into a heap of OOP !

    Coming soon...

    learning Object Oriented Programming...

          OR

    OOP ! I did it again !!! - A lesson in object cloning...

     

     

    At the end you will be able to snatch the pebble from my hand...

     

    You down with  OOP ! - Yeah You Know Me !!!


    Tags:
    Categories: C#
    Posted by Admin on Tuesday, May 06, 2008 7:19 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Using Namespace Alias Qualifier (C# Programming Guide)

     

    The ability to access a member in the global namespace is useful when

    the member might be hidden by another entity of the same name.

    In this example, the namespace System is used to include the class TestClass therefore, global::System.Console must be used to reference the System.Console class, which is hidden by the System namespace. Also, the alias mcLovin is used to refer to the namespace System.Collections; therefore, the instance of a System.Collections..::.Hashtable was created using this alias instead of the namespace.

      
    

    Posted by Admin on Wednesday, April 30, 2008 8:37 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    When Multi threading unsafe COM Win32 code always specify a seperate apartment model

    A .NET thread is automatically assigned an apartment upon entering apartment-savvy Win32 or legacy COM code. By default, it will be allocated a multi-threaded apartment, unless one requests a single-threaded apartment as follows:
     Image Preview
    
    Thread t = new Thread (...);
    
    t.SetApartmentState (ApartmentState.STA);
    
    One can also request that the main thread join a single-threaded apartment using the STAThread attribute on the main method:
    class Program {
    
      [STAThread]
    
      static void Main() {
    
      ...
    
    Apartments have no effect while executing pure .NET code. In other words, two threads with an apartment state of STA can simultaneously call the same method on the same object, and no automatic marshalling or locking will take place. Only when execution hits unmanaged code can they kick in.The types in the System.Windows.Forms namespace extensively call Win32 code designed to work in a single-threaded apartment. For this reason, a Windows Forms program should have have the [STAThread] attribute on its main method, otherwise one of two things will occur upon reaching Win32 UI code:
    • it will marshal over to a single-threaded apartment
    • it will crumble and fail.

    Posted by Admin on Wednesday, April 30, 2008 4:29 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Who wrote this piece of code ?

    Don't complain about BAD code you come across, Just fix it. Usually you are not privy to the exact situation surrounding the code you see before you.

    It's easy to criticize older code someone else has written, but we have all written code that could be better. 

    Ever come across a section of code, and say to your self... "Whoa! This sucks!” I wonder what the developer was thinking here.
    Then you look further down and realize you wrote it 2 years ago late at night when you had the flu.
     
      

        + =

    You can almost always refactor your code to make it more streamlined, readable and efficient.  But not everyone has the time, or makes time to do so.
    The important message here is to "Just fix it " but be carefull there could be good reasons for the decisions made to code this solutiuon in a particular way.

    More to come...


    Categories: C# | LINQ | SQL Server | XNA
    Posted by Admin on Tuesday, April 29, 2008 3:10 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Over Engineering Software Design

    Need more cow bells ?

     Over engineering your software application is when you attempt to make it so flexible or scalable that you lose focus on returning business value. Often you can get swept up in programming and designing just for the sake of doing so.  It’s so tempting to use that “New” technology to tackle any problem that comes your way with a cool design pattern or “the tool of the month”.  Some programmers attempt to make their software very flexible and sophisticated because they believe they know their system’s future requirements.  In there programmer minds they reason that it's best to make a design more flexible or sophisticated, so it can accommodate the needs of tomorrow. This is perfect if you have a crystal ball or are psychic.  Ok you may be saying…”Yeah but based on my experience, I believe I have a handle on this business domain enough to predict the future of this software development.”


    Ok, but what if you're wrong ?... If your predictions are wrong, you waste precious time, resources and money.  Then you and your team will spend days or even weeks tweaking an overly complex “flexible” piece of code.  This is time you could have spent writing the new logic exactly the way it should be to provide business value.

     

    Except for the guys that work at a R&D software think-tank most of us have a business need that drives our software development, which in turn drives our paychecks.

    To turn your back on business value is to bite the hand that feeds you.

     

     


    Tags:
    Categories: C# | LINQ
    Posted by Admin on Monday, April 28, 2008 9:25 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    What would you say... ya do here?

    Remember middle managment needs to look important also !!!


    Posted by Admin on Monday, April 28, 2008 8:01 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    LINQ with Transactions

     This is a simple example of how to wrap your LINQ db.DataContext SubmitChanges() in a Transaction.

    This is much like using transaction in SQL Server.

    I used a simple add function to outline the pattern to use when wrapping your LINQ commits in transactions.

    *Add a ref to System.Transactions;

     

     

      
      
    New LINQ the home verion. now you and your friends can play "Map that Relational Object" on a Friday Night !!!

    * Some assembily required.

       (database not included)

     

     

      using System.Transactions;


    Categories: C# | LINQ
    Posted by Admin on Thursday, April 17, 2008 9:30 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Increase IE's number of simultaneous downloads

    I do not like being restricted by IE's limitation on only allowing 2 simultaneous downloads.

    Click on the Start button and select Run.

    1. On the Run line type Regedt32.exe and hit Enter. This will launch the Registry Editor
    2. Locate the following key in the registry:

      HKEY_CURRENT_USER>Software>Microsoft>Windows>
      CurrentVersion>Internet Settings
      .

    3. Click on the Internet Settings Key. Now go to the Edit menu, point to NEW click DWORD Value
    4. Type MaxConnectionsPer1_0Server for the name of this DWORD Value.
    5. Double-click on the MaxConnectionsPer1_0Server key you just created and enter the following information:
      • Value data: 10.
      • Base: Decimal.
    6. When finished press OK.
    7. Repeat steps 4 and 5. This time name the key MaxConnectionsPerServer and assign it the same values as indicated in Steps 6.
    8. Close the Registry Editor.

    That's all there is to it! If you modified your registry settings correctly, you should now have the capability to download up to 10 files simultaneously.

     

     


    Tags: ,
    Posted by Admin on Monday, March 24, 2008 5:50 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Welding in custom assemblies in SSIS with configuration variables.

     Welding in custom assemblies in SSIS with configuration variables. 

    (I will pop a GAC in your CACHE !!!!)

    Pre-requisites

    SQL Server 2005 (including SSIS), Microsoft Visual Studio 2005 / 2008, .NET Framework v2.0-3.5

     

    Prep the Assembly

    In order to register the assembly in the Global Assembly Cache (GAC), it is necessary that the assembly has a Strong Name. There is a utility called sn.exe that can be used for this purpose. However, for this project, navigate to the Signing tab, select Sign the assembly option, and select <New> from the drop-down list. Type a name for the strong name key file. Finally, uncheck the option to protect my key file with a password. Click OK and save the project file. Build the file.The final step is to register the component in the GAC.  The simplest way is to copy your assembly into the C:\WINDOWS\assembly folder by dragging and dropping.  The other method involves creating bat files or using the command prompt to register your component. 

    Adding a reference to the Assembly in SSIS script designer

     Intuitively one would think your next step is to open your SSIS script editor and within your project explorer simply add a reference to your newly GAC’ed assembly.  However when you right click on References -> Add Reference and browse the list of available assemblies - yours is not there.I will not spend time trying to explain the intricacies of why this is, instead I will focus on how to get your .dll registered so you can get up and working.  The bottom line is your going to have to modify the Package.dtsx manually edit the *.dtsx script file to add additional paths to look for your defined assemblies. For example:  Open the file and first search for “<Build>”.

    Add yours to the end of the ReferencePath attribute. 

    <Build>         
    ReferencePath = "C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.ScriptTask\9.0.242.0__89845dcd8080cc91\;
    C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS\9.0.242.0__89845dcd8080cc91\;
    C:\WINDOWS\assembly\GAC_MSIL\ myAssembly \1.0.0.0__5d6caf3fc6396ac3\"

    Then you can define you assemblies in the References Tags a little further down:
     

    <References>           
    <Reference Name="
    myAssembly " AssemblyName=" myAssembly " /> 
                *Next time you fire up the script in Visual Studio of Applications it will be referencing Next Search for “<References>”.  

    <References>
                   
               
    <Reference Name = "myAssembly" AssemblyName = " myAssembly "/> 
    </References>

    Using a configuration varibles.

     When you are using a .NET assembly that reference external config variables, the hosting executable “owns” the App.config file.  Therefore in this instance, SSIS has two executables that it uses one for the development and debugging and one for the production release.  To see these files browse to:
     
    C:\Program Files\Microsoft SQL Server\90\DTS\Binn

    If you’re going to use configuration variables you need to add them to these two .config files:
     DTExec.exe – The main .exe SSIS uses for production release.

    DTExec.exe.config 
    DtsDebugHost.exe – The .exe  SSIS uses when developing and debugging.

    DtsDebugHost.exe.config 

    <configuration>   
    <startup>
           
    <requiredRuntime version="v2.0.50727"/>
       
    </startup>
       
    <appSettings>
                   
    <add key="Test1" value="test1" />
                   
    <add key="Test2" value="test2" />
        
    </appSettings>
    </configuration>

    Categories: Cars
    Posted by Admin on Thursday, March 13, 2008 4:13 AM
    Permalink | Comments (0) | Post RSSRSS comment feed

    LINQ Books - The future of Data Access

    LINQ Books

    Books on LINQ

    LINQ in Action by Fabrice Marguerie, Steve Eichert, Jim Wooley, and Matt Warren



    Pro LINQ: Language Integrated Query in C# 2008 by Joseph C. Rattz

    Professional LINQ (Programmer to Programmer) by Scott Klein

    LINQ Quickly by Satheesh, N Kumar

    LINQ for VB 2005 by Fabio Claudio Ferracchiati


    Books that Feature LINQ

    C# 3.0 in a Nutshell: A Desktop Quick Reference by Joseph Albahari

    Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition (Pro Series) by Andrew Troelsen

    C# 3.0 Cookbook by Jay Hilyard and Stephen Teilhet

    Pro ASP.NET 3.5 in C# 2008, Second Edition by Matthew MacDonald and Mario Szpuszta

    ASP.NET 3.5 Unleashed by Stephen Walther (Hardcover - Jan 7, 2008)


    Posted by Admin on Thursday, March 06, 2008 7:35 AM
    Permalink | Comments (0) | Post RSSRSS comment feed
    Free Hit Counters
    page counter