asp.netwebformsmodel-bindingasp.net-4.5webformsmvp

Value converter for ASP.Net Webforms


I'm putting together a web forms application that is utilizing the WebFormsMvp library. In the examples, it shows something like this in the ASPX markup:

Name:
<asp:TextBox runat="server" 
             ID="txtName" 
             Text="<%# Model.Name %>" 
             Visible="<%# Model.ShowName %>" />

This is allowed outside of a binding container (e.g. grid, repeater, etc.). It reminds me of MVVM style programming in WPF. What I'm missing is a value converter so I can setup how values should be converted. I suppose I could do this with extension methods for the types on the Model, but that doesn't seem like it has very good separation between the View and the code.

Ultimately I have two questions:


Solution

  • I might be thinking about this too much as the following seems to work great:

    Name:
    <asp:TextBox runat="server" 
             ID="txtName" 
             Text="<%# Model.Name %>" 
             Visible="<%# !String.IsNullOrEmpty(Model.Name) %>" />
    

    This is almost as good as a value converter.