Iver's web place

Life is a journey ... taken one shot at a time!

CSharp

  • Compartamos código

    Cuando desarrollas aplicaciones de software a distancia, es común querer compartir código pero tenemos la limitante de que al hacerlo por correo no se ve el realzado de sintaxis y por mensajero es limitado el envío por los emoticons, el número de líneas o bien simplemente queremos que persista la información para un post en nuestro blog.
    Claro que algunos blogs como Jaws, permiten compartir un código como el siguiente y con sus respectivos tags.
       1:  ParameterExpression pc = Expression.Parameter(typeof(Customer), "c");
       2:  
       3:  IQueryable<Customer> q3 =
       4:      dc.Customers.Where<Customer>
       5:      (
       6:          Expression.Lambda<Func<Customer, bool>>
       7:          (
       8:              Expression.Equal(
       9:              Expression.Property(pc, typeof(Customer).GetProperty("City")),
      10:              Expression.Constant("London", typeof(string))
      11:          ),
      12:          new ParameterExpression[] { pc }
      13:          )
      14:      );
     
    Read More...
  • How to create custom controls in ASP.NET part 3 of 3

    Deploying Custom Controls

    If you're using the Visual Studio IDE, maybe you don't know the building way from the command line. I have two files (FoxyGridView.cs and FoxyGridView.Methods.cs) and I need to generate the build from the command line. So the sintax is the next:
    C:\Program Files\Microsoft Visual Studio 9.0\VC> csc /t:library /out:FoxyGridView.dll /r:System.dll /r:System.Data /r:System.Drawing /r:System.Web FoxyGridView.cs FoxyGridView.Methods.cs

    Also we can set the control assembly properties, a strong assembly name consists of four parts: assembly name, version, culture, and public token key. Only we need to create a file named AssemblyInfo.css (or maybe other name), with the following code to the file:
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    [assembly: AssemblyCulture("")]
    [assembly: AssemblyVersion("1.0.0.0")]
    [assembly: AssemblyKeyFile("KeyFile.snk")]
     
    Read More...
  • How to create custom controls in ASP.NET part 2 of 3

    State Management

    Previusly in the last post we saw the web custom controls attributes. We can interactive with the web user control through its attributes.
    To implement a custom control, you have to implement a class in procedural lenguages as C# or VB.NET that derives from a base class such as Control. Every server control directly or indirectly derives from the Control base class.
    The base class Control provides server controls with the infrastructure they need to operate as a server control in the ASP.NET framework. One of these infrastructural methods is a method named Render. This method is where a server control generates or renders its HTML markup text.
    For example, if you wish to put a html table into the page, you need to use the next code or similar code:
    Read More...
  • How to create custom controls in ASP.NET part 1 of 3

    This is my first post in English, I need more practice so ... If you find some error in my redaction, feel free to comment about it.
    For understand the topic is necesary to know the basic differences between user controls and custom controls:
    User Control
    • Designed for single-application scenarios
    • Deployed in the source form (.ascx) along with the source code of the application
    • If the same control needs to be used in more than one application, it introduces redundancy and maintenance problems
    Custom control
    • Designed so that it can be used by more than one application
    • Deployed either in the application's Bin directory or in the global assembly cache
    • Distributed easily and without problems associated with redundancy and maintenance
    OK, After that I want to show you how we can create a custom control in ASP.NET for this I split the post in 3 parts:
    Read More...