patterncsharpMinor
Accessing server side variables in views and JavaScript
Viewed 0 times
javascriptsideandviewsvariablesserveraccessing
Problem
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
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
Back to Emp Info
. ..... .. .. ...
$(document).ready(function () {
EmpWorkingDays = [, , , , , , ];
Holidays.push({date:new Date("", "", "",0,0,0,0).getTime(), holiday:""});
});
Solution
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
Other than that, this is really easy code to read. Keep it up.
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.
Context
StackExchange Code Review Q#43399, answer score: 5
Revisions (0)
No revisions yet.