I'm new with ASP.NET MVC, at the cshtml I have some style:
.circle {
border: 2px solid red;
background-color: #FFFFFF;
height: 100px;
border-radius:50%;
width: 100px;
}
<div class="circle"></div>
And I want to change the circle position from the controller, I can I achieve that? In the controller I need something like:
circle.MarginLeft = 120;
You can use your model or ViewBag.
In controller pass your data into an object like circle.MarginLeft = 12 or use ViewBag['marginLeft'] = 12
and in your .cshtml file set
<div class="circle" style="margin-left:@ViewBag.marginLeft"></div>
or
<div class="circle" style="margin-left:@Model.marginLeft"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With