在 ASP.NET 中使用枚举参数和 Eval 调用方法
Call method with enum parameter and Eval in ASP.NET
我在页面 class
上有这个方法
public string GetTranslations(UITranslations uiTranslation)
{
return ((AppUICulture)Application["UICulture"]).GetTranlsation(uiTranslation);
}
我想用
这样的字符串填充占位符
<input class="full-width has-padding has-border" id="inpLogId" type="text" placeholder='<%# GetTranslations( UITranslations.LOGIN_ID ) %>' required>
其中 UITranslations
是一个 enum
。
如何正确使用 Eval
来完成它?
如果您想使用 Eval,您需要创建绑定上下文。最简单的选择之一是使用 FormView。这是示例:
<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>
我在页面 class
上有这个方法public string GetTranslations(UITranslations uiTranslation)
{
return ((AppUICulture)Application["UICulture"]).GetTranlsation(uiTranslation);
}
我想用
这样的字符串填充占位符<input class="full-width has-padding has-border" id="inpLogId" type="text" placeholder='<%# GetTranslations( UITranslations.LOGIN_ID ) %>' required>
其中 UITranslations
是一个 enum
。
如何正确使用 Eval
来完成它?
如果您想使用 Eval,您需要创建绑定上下文。最简单的选择之一是使用 FormView。这是示例:
<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>