Accessing server side variables in views and JavaScript I was a PHP developer and I started writing a product in C# without studying the basic structure. Now, I have around 100+ views with similar code. After 1 year into development, I now realize that something is not right.

How can I separate the server tags when they are so intertwined in the code? Is it okay to use server side variables like this?

PS: I am not using Razor in my product.

/Views/Emp/EditEmp.aspx

&lt;% if(HttpContext.Current.User.IsInRole("Manager")) { %&gt;
    &lt;div class="small right" style="margin:5px 0 10px 0;"&gt;
        &lt;a class="btn" href="/Emp/Edit"&gt;&lt;i class="icon-double-angle-left"&gt;&lt;/i&gt;Back to Emp Info&lt;/a&gt;
    &lt;/div&gt;
&lt;% } %&gt;

&lt;div&gt;. ..... .. .. ...&lt;/div&gt;

&lt;script type="text/javascript"&gt;
$(document).ready(function () {
    EmpWorkingDays = [&lt;%= Model.SundayWorkingTime %&gt;, &lt;%= Model.MondayWorkingTime %&gt;, &lt;%= Model.TuesdayWorkingTime %&gt;, &lt;%= Model.WednesdayWorkingTime %&gt;, &lt;%= Model.ThursdayWorkingTime %&gt;, &lt;%= Model.FridayWorkingTime %&gt;, &lt;%= Model.SaturdayWorkingTime %&gt;];
    &lt;% if(Model != null &amp;&amp; Model.Holidays != null){
        foreach(EmpHoliday eh in Model.Holidays.ToList()) { %&gt;
            Holidays.push({date:new Date("&lt;%: eh.Date.Year %&gt;", "&lt;%: eh.Date.Month - 1 %&gt;", "&lt;%: eh.Date.Day %&gt;",0,0,0,0).getTime(), holiday:"&lt;%: eh.Holiday %&gt;"});
        &lt;% }
    } %&gt;
});
&lt;/script&gt;


&lt;% if(Model != null &amp;&amp; Model.Holidays != null) { 
    foreach(EmpHoliday eh in Model.Holidays){ %&gt;
        &lt;div class="editor-label"&gt;&lt;%= eh.Date.ToString("dd/MMM/yyyy") %&gt;&lt;/div&gt;
        &lt;div class="editor-field"&gt;&lt;%= eh.Holiday %&gt;&lt;/div&gt;
    &lt;% } %&gt;
    &lt;div class="clear"&gt;&lt;/div&gt;
&lt;% } %&gt;
This is how I see server variables and local variables interacting.  There is not really any other way to get the values between the two that I'm aware of.

As for the code, I one minor point:change Emp to Employee for variable names.  This will eliminate confusion in the future from you, or anybody else reading the code (what does Emp mean?)

Other than that, this is really easy code to read.  Keep it up.