ashkufaraz
ashkufaraz

Reputation: 5297

how can declare variable of <div>

how can declare a variable of type <div> in asp.net

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

Code

 get(b);

private void Get(<div> d)
{
  d.Visible=false;

}

i can do this work?How can...

Upvotes: 1

Views: 4821

Answers (3)

Brandon
Brandon

Reputation: 70012

Use an HtmlGenericControl to declare a div on the server side.

var div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");

The answer is still the same, use an HtmlGenericControl.

private void Get(HtmlGenericControl d)
{
   d.Visible = false;
}

Upvotes: 4

Gate
Gate

Reputation: 495

used System.Web.UI.HtmlControls.HtmlGenericControl

Get(b)

private void Get(System.Web.UI.HtmlControls.HtmlGenericControl d) { d.Visiable=false;

}

Upvotes: -2

Babak Naffas
Babak Naffas

Reputation: 12561

Within ASP.NET itself, you can just use a <DIV> no problem. IF you want to access it from the code behind, you can use line like any other contrl

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

If you're trying to generate one in your code behind, you can use the HtmlGenericControl.

Upvotes: 1

Related Questions