During development, I want to enable borders for all columns temporarily for visual design purposes only. Is there a simple way to achieve this?
Based on your question, it seems like we have the container column class name
and the Environment
. In that case, there is an easy method to meet your requirements.
Retrieve Environment Variable:
We can start by checking the Environment Variable
using the following code snippet.
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Check The Environment:
Now that we know the app environment
, we can verify it with a simple conditional statement as shown below.
@{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (env == "Development")
{
}
}
Manipulate Your DOM:
@{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (env == "Development")
{
@section Scripts{
<script type="text/javascript">
alert('@env')
$(".col").css({ "border": "Solid red 2px" });
</script>
}
}
}
HTML:
<div class="container">
<div class="row">
<div class="col">Left column</div>
<div class="col">Middle column</div>
<div class="col">Right column</div>
</div>
</div>
Output:
https://i.sstatic.net/VEisF.gif
Note: This is the most straightforward way to accomplish this task. Hopefully, you will find it useful.