I have a div with id _box1
My on click event accesses the c# routine below:
private void Expand_Ratings(object src, EventArgs e)
{
_box1.Style["background-color"] = "Red";
}
when I run the compiler I get:
Compiler Error Message: CS0103: The name '_box1' does not exist in the current context
Can anyone please assist
You need to add runat="server"
attribute to the tag in HTML code tobe accessible from server side code.
Try This:
<DIV ID="_box1" runat="server">
</DIV>
You should add runat="server"
to your div.
And then you should do this:
_box1.Attrbutes["style"] = "background-color:red";
Yes at runat server in the div.
<div ID="_box1" runat="server">
</div>
In the code behind..
_box1.Width = 300;
_box1.Height = 300;
_box1.Visible = false;
or by CSS
_box1.Style["Height"] = "300px";
_box1.Style["Visible"] = "false";
Good luke
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.