asp.net - Using Methods in Serverside ControlIDs -
i got following code on asp-site
<asp:repeater runat="server" id="repfoo"> <itemtemplate> <asp:button runat="server" id="btnfoo" visible='<%#!string.isnullorempty("foovalue")%>' /> </itemtemplate> </asp:repeater>
how correct syntax string.isnullorempty method?
there 2 ways :
declare function in cs file value , make checks on it:
<asp:button runat="server" id="btnfoo" visible='<%# checknull(eval("foovalue")) %>' /> public bool checknull(object value) { return string.isnullorempty(value) ? fale : true; }
or use function isnullorempty
inline :
<asp:button runat="server" id="btnfoo" visible='<%# string.isnullorempty(eval("foovalue").tostring()) ? false : true %>' />
Comments
Post a Comment