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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -