Tag: c#

Using Autofac in a ASP.NET MVC 4 application

Posted by – October 18, 2012

ASP.NET MVC is a great framework, very flexible, but sometimes we need to organize a little better our business logic, there’s nothing better than have a business logic completely decoupled from controller, which can be easily reused on several controllers over the project.

To help ASP.NET MVC make use of reusable business logic and other logic components aswell, we can add a DI/IoC container to our project, after few days researching about IoC container alternatives, I choose Autofac to create my first web application that takes advantage of Dependency Injection.
More

Share

Fixing SelectedValue issue on DropbDownListFor with SelectList

Posted by – July 30, 2012

After spent several hours trying to figure out how the SelectedValue works on DropDownListFor, I finally figure out how to do it, you can also check my answer on stackoverflow here.

It’s very simple to get SelectList and SelectedValue working together, even if your property isn’t a simple object like a Int, String or a Double value.

Example:

Assuming our Region object is something like this:

1
2
3
4
public class Region {
     public Guid ID { get; set; }
     public string Name { get; set; }
}

More

Share

Data driven application with GTK+ and APR DBD routines

Posted by – June 19, 2010

I have been trying to find a reason to study c programming for a long time, now I found a reason to do it, I wrote a very small application that uses APR and GTK+ where I can manager costumers and suppliers contact info.

Before start coding you must pay attention to the following requirements:

  • Apache APR
  • GTK+
  • pkg-config

All the requirements above can be easily installed in your system by using the linux distribution package management system, you can also visit their respective sites to download the sources, compile them and install the binaries. The Apache APR sources can be found at apr.apache.org and GTK+ sources at gtk.org
More

Share

Back with Windows Mobile development

Posted by – May 19, 2008

Today I’m working with four mobile platforms:

At work:

  • Symbian

At home:

  • J2ME
  • Qtopia
  • Windows Mobile

After some years without touch in Visual Studio .NET and a little far away from Windows Mobile development, I’m finally back, now working on a small project for use in restaurants using a wi-fi connection.

I’ll post some of my challenges in this project when possible.

Share

ASP.NET MVC, good or bad?

Posted by – March 15, 2008

I have been listening some screencasts about ASP.NET MVC, at first moment we can see few features found on the other web frameworks like Grails and RoR, the controllers are very easy to write and all controllers actions can be bind easily on your view code by using helper methods.

The default view engine of ASP.NET MVC is terrible, remembers the way that we wrote some ASP and PHP pages in the past, if you need more control over page rendering you must place some conditional statements there, take a look on the code block below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<form action="/App/InsertCustomer">
  <% if (ViewData.ErrorMessage != null) { %>
    The following error occurred while inserting the customer data:
    <br />
    <%= ViewData.ErrorMessage %>
    <br />
  <% } %>

  First name: <input type="text" name="firstName"
      value="<%= ViewData.FirstName %>" /><br />
  Last name: <input type="text" name="lastName"
      value="<%= ViewData.LastName %>"  /><br />

    <input type="submit" value="Insert" />
</form>

Note the presence of ASP tags <%= somecode %>, this kind of web page code can be very easy to understand on small pages, but if your pages start to be bigger and bigger you will have some problems with code readability, I don’t like this kind of view coding, it can turn into a nightmare.

But, in other hand, you can put all this mix of markup and C#/VB code into an ASP.NET user control, separating small pieces of reusable code into .ascx files, with this approach you can reduce the amount of non markup code into your page and all page rendering logic will be a little more easier to understand.

Share