Creating table using C# vs using Javascript/jQuery + Json [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
This may look like an opinion-based question but the reason I am asking this is to come up with an explanation on why I should use the other versus the other.
Scenario:
I am a new intern in this company where they have lots of ASP.NET MVC projects and one thing I noticed is that they are building a large row of tables using c# foreach loop like so:
#foreach(var i in Model)
{
<tr>
<td>#i.Name</td>
<td>#i.Amount</td>
<td>#i.SomethingElse</td>
</tr>
}
And I made a comment to my co-intern that it looks "stupid" and it makes the server do unnecessary workloads that can be done with javascript (so the workload is passed on to the client computer instead).
Then I didn't notice that the company developer was behind us and told me to prepare a list of reason how I can improve it and why I think that their "way" is stupid.
I am somehow new to programming and do not really know the ins and out of things but I know something is wrong with such practice (or not?). Can anyone give me a solid argument or explanation why I should pick the other over the other one?

"There is nothing wrong with this". That is the first thing I can confirm with you.
Even though I recommend you to read more about MVC, but in short, it doesn't increase the workload for server.
With MVC, there are 2 ways (as I know) to display data.
Traditional way like your company. Loading every data to a Model, and using View to display Model. This is how MVC design pattern work.
Return all bunch of datas to an interchange format (json, xml, but mostly is json), using Java-script to display those data.
Since I said there is nothing wrong, there will be pros and cons, and Method_1's pros is Method_2's cons: (in my opinion, will update more after research on other pros and cons)
Pros:
With method 1, it will be easier to control with Razor syntax / C# syntax.
Correct format of MVC.
If using Method_2, you may need to copy-paste a lots of JavaScript if you have similar pages on same projects
Cons:
it will be complicated when you are required to load more than one Model in a View.
Does not apply if you has multiple Front-end.

Related

Similar and simplified examples (newbie questions) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm currently studying about web development, I still don't know about jquery, but I've a little knowledge about javascript, html and css (basic).
I've been looking at some examples in github to improve my skills, and I've found this content;
https://github.com/stewilondanga/editables
I perfectly understand the theory, but I do not know how to put it into practice, I would like for any similar examples (simplified alternatives) and how to convert the exported code generated by javascript into a html5 table?
Any example would be appreciated! thanks for your attention!
First of all, jQuery does not generate code. It's a framework, you load it into a web page, and then you can use it from within Javascript code in that page.
I suggest you start by looking at the source of https://stewilondanga.github.io/editables/, if an editable tables is what you need. There are more general frameworks to do this, e.g. Aloha
To try it yourself, I'd suggest you bite the bullet equip yourself with some kind of web server, be it on a server somewhere, or on your local machine, so you can easily try out things like this, copy the sources, alter the code etc.., and quickly hit reload on your browser.
While it may seem easier to run a local server and point your browser at http://localhost/something, IMHO it also takes more tinkering to get browsers to embrace that fully. You don't need the extra grief while already learning all those new concepts. If you want to tackle this seriously, consider getting a hosting service or small VPS somewhere. If you don't know how to do that, get help for that first, but get it out of the way. It'll save you much grief.

Getting updating in codebehind C# variable to asp.net [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I wrote a small code in c# that reads files from the hard drive and outputs that info to a webpage using asp.net.
Information about those files is being changed in the codebehind.
I managed to create variables to read and display the info on the webpage, but they change only after a refresh. When I used setTimeout it would always read the same variable, leaving me thinking that the codebehind does not get re-executed.
How would it be possible to have them updated live without needing to refresh the entire page?
This is somewhat vague but if you want updates to the values on your page after loading, you'll need to use some javascript to grab new values and then more javascript to update values on your page.
There are some great frameworks out there. Unless you have a lot of front-end logic you need to perform through javascript, I'd keep it as simple as possible and throw jQuery in there for the AJAX calls (fyi, this is not the only solution, there are 10+ different ways to skin this same cat).
If you want a bit more efficiency, you could look into using SignalR - which wraps long polling or web sockets (depending on browser capability) on the front end and signals those subscribing pages on the backend only when changes have occurred to data.
Link: http://www.asp.net/signalr
There is no "right" answer to your question so the best I or anybody can do is guide you in a direction. Hopefully this answer helps you.

Is angularjs a good fit for large datacentric enterprise web application [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am trying to build a web application which will have many different pages. each page mainly shows data in table and various graphs based on data.
I want to decouple front end completely from the backend. for this reason I am considering angularjs.
My concern is following two points:
angular js is considered best for SPA style applications
angularjs will load the partial view when required and will load data through ajax, every page needs at least two seperate http requests to render the page.
Is it really a good choice to select angular or any better approach?
I think that using Angular is a good solution, I am working in a very big project, that manage a lot of data and angular is working perfectly.
There are a lot of advantages of using Angular. However, I think that it depends on your needs, if you don't need a rich experience of user, maybe you can select other option different from a SPA that could be faster, if you don’t have experience developing a SPA..
I think that in your case, it is most important choosing well the backend technology than the frontend technology, because the responsibility of managing the data is from the backend.
I hope that helps.
Angular JS is a good for these kind of applications.
1.) Angular JS simplifies your code.
2.) It builds on HTML so you don't have to learn something entirely new and it is fast to catch up.
3.) It has a large community so you can get help on topics easily.
4.) It is continuously evolving.
5.) It is based on MVC structure.
P.S: Read on dirty checking part of angular as it is considered best in some scenarios and not so good in others. It is considered to keep no. of objects to 1000 or less while using angular for good performance.
Hope that helps! :)
From my experience I would say yes, is good. But maybe you can see with your eyes some case studies and applications built with angular: builtwith.angularjs.org.
Check this blog post also: Building large apps with AngularJS.

Building a JavaScript grid from scratch [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am curious to know what it takes to build a JavaScript grid from scratch. The grid should have features like jqGrid http://www.trirand.com/blog/jqgrid/jqgrid.html.
Can anyone please give me inputs?
Thanks
What it takes to build something similar to jqGrid:
A huge, HUGE amount of time.
If something similar to what you want exists already, why would you want to spend lots and lots of time re-inventing the wheel? Anyhow, if you have nothing better to do, want to learn from it or if you are just curious, here is a list of skills that are needed to create a similar system:
HTML object manipulation.
Style manipulation.
Tons of different event handlers.
AJAX to grab (pages of) documents to display. Probably some server-side stuff too...
Creating of a nice layout system wich works in every browser.
Creating handlers to read and manage the different file types to support (XML, JSON, etc)
Creating HTML forms and reading them out with JS and then use AJAX to resave an XML, JSON, etc document back to the server.
An Algorithm to allow searching in the data you display.
Keyboard manipulation and the toggling off of standard key-events.
10. Tons and TONS of debugging to make sure it looks nice in all browsers.
Of course, this is only a tip of the iceberg since I don't really know the jqGrid program myself. I created this list by looking at some of the examples and reading the Features page.
Again, I would not recommend to rebuild such a big system from scratch, but the choice is of course yours ;).

Is there a guide about how to create beautiful HTML that is preped to be used with javascript? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This might seem like an odd question, but I find that javascript is either easy or hard, depending on how you've coded the HTML. Is there a book or website that goes into detail about successful patterns and guidelines for coding HTML, so that it's very workable with jQuery, css and complex ajax applications? Like solid rules to live by.
Again, seems like a weird question maybe, but I don't know a better way to ask it. I just find myself always having to change the markup as new things come up - like switching between a hidden input element to a data attribute... or putting more ids or taking away ids - and I guess I arrive at the right way to do it, but I'm curious if someone has bothered to analyze this and came up with some great guidelines, standards and patterns so that the resultant HTML is right the first time.
Thanks
The first thing if you want to code some clean HTML that will be easy to work with is to make sure that your code is valid against an official DTD, HTML4 (here) or XHTML (here).
Then use id and class in a proper way (id only for unique section and class for repeatable ones) and name them correctly according to the context so they are easily reachable.
From my experience, I would actually suggest that, when it comes to large projects and professional JavaScript coding, the goal actually becomes to decouple the JavaScript code from whatever HTML it lives in.
As mentioned already, as long as you are using well formed HTML (DTD compliant), a library like jQuery shouldn't have any trouble operating on it. However, as best practice, I would recommend striving to isolate and encapsulate dependencies, whether they be because of HTML structure or just other chunks of JavaScript code.
the best way is to develop the html and javascript together. That way you can adjust the document structure to whatever you need.
This article seems to answer my question:
http://www.viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution/

Categories

Resources