Dimi Dimi - 1 month ago 15
ASP.NET (C#) Question

Call method with enum parameter and Eval in ASP.NET

I have this method on page class

public string GetTranslations(UITranslations uiTranslation)
{
return ((AppUICulture)Application["UICulture"]).GetTranlsation(uiTranslation);
}


And I want to populate placeholder with string like

<input class="full-width has-padding has-border" id="inpLogId" type="text" placeholder='<%# GetTranslations( UITranslations.LOGIN_ID ) %>' required>


Where
UITranslations
is an
enum
.

How do I properly use
Eval
to get it done?

Answer

If you want to use Eval you need to create binding context. One of the easiest options would be to use FormView. Here is sample:

    <asp:FormView ID="FormView1" runat="server" DefaultMode="Insert">
        <InsertItemTemplate>
            <input runat="server" class="full-width has-padding has-border" id="inpLogId" placeholder='<%# this.GetTranslations( UITranslations.LOGIN_ID) %>' />
        </InsertItemTemplate>
    </asp:FormView>
Comments