CALLING DIV FROM CODE BEHIND C#

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
C# 
C#
 4324  View(s)
Ratings:
Rate this:

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)

            }

        }

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Calling div from code behind c#

    Hi Jayden,

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!