简体   繁体   中英

Calling div from code behind c#

 <blink>in condition i want to call div from html , which contains background image only, and I need to call it on just few pages 

with same metadata. So how will i call that div, i tried few ways but nothing helped me.

 if (cMeta != null && cMeta.Name == "background")
        {
            if (cMeta.Text == "Yes")
            { 
                Display(Div)
            }
        }

Thanks

Set runat="server" to div markup.

<div id="myDiv" runat="server"></div>

Now in code behind you can access the myDiv

private void DisplayDiv(bool isShow)
{
   myDiv.Visible = isShow;
}

Now when you want to show it then just call this function with true value

DisplayDiv(true);

otherwise just call it with false ,if you don't want to show it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM