Here is the snippet of my code:
/Views/Emp/EditEmp.aspx
<% if(HttpContext.Current.User.IsInRole("Manager")) { %>
<div class="small right" style="margin:5px 0 10px 0;">
<a class="btn" href="/Emp/Edit"><i class="icon-double-angle-left"></i>Back to Emp Info</a>
</div>
<% } %>
<div>. ..... .. .. ...</div>
<script type="text/javascript">
$(document).ready(function () {
EmpWorkingDays = [<%= Model.SundayWorkingTime %>, <%= Model.MondayWorkingTime %>, <%= Model.TuesdayWorkingTime %>, <%= Model.WednesdayWorkingTime %>, <%= Model.ThursdayWorkingTime %>, <%= Model.FridayWorkingTime %>, <%= Model.SaturdayWorkingTime %>];
<% if(Model != null && Model.Holidays != null){
foreach(EmpHoliday eh in Model.Holidays.ToList()) { %>
Holidays.push({date:new Date("<%: eh.Date.Year %>", "<%: eh.Date.Month - 1 %>", "<%: eh.Date.Day %>",0,0,0,0).getTime(), holiday:"<%: eh.Holiday %>"});
<% }
} %>
});
</script>
<% if(Model != null && Model.Holidays != null) {
foreach(EmpHoliday eh in Model.Holidays){ %>
<div class="editor-label"><%= eh.Date.ToString("dd/MMM/yyyy") %></div>
<div class="editor-field"><%= eh.Holiday %></div>
<% } %>
<div class="clear"></div>
<% } %>
Is it okay to use server side variables like this?
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?
PS: I am not using Razor in my product.