Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing a div tag from codebehind

Tags:

c#

asp.net

I am Working in asp.net and c#. I have a div tag in my application with class="something".I need to access this something class in codebehind.How can i do that..

Code:

 <div class="something">
//somecode
 <div>

Note:I want access Something class in codebehind.

like image 308
smith269 Avatar asked Feb 18 '13 06:02

smith269


2 Answers

Give ID and attribute runat='server' as :

<div class="something" ID="mydiv" runat="server">
//somecode
<div>

Codebehind:

You can modify your something styles here.

mydiv.Style.Add("display", "none");
like image 163
coder Avatar answered Sep 22 '22 22:09

coder


Make it a server tag if you want to access it in CS code.

<div class="something" runat="server" id="something">
//somecode
 <div>

asp.net does not provide a method to search by classes. so you will have to rely on the ID.

CS:

something.InnerHtml = "some code";
like image 34
nunespascal Avatar answered Sep 19 '22 22:09

nunespascal