calculating total using angularjs and webforms usercontrol - asp.net

Im new to using angularjs with webforms.
i am using asp.net 4.0 webforms project. It have a usercontrol(uc.ascx) with a textbox and I dynamically multiple of the usercontrols on a page(Default.aspx)..on this aspx page i have a text box which should display the sum of the values in the textboxes of the dynamically added usercontrol..
can some one help me on how i can achieve this?
I researched all over the internet but could find a proper tutorial that works with usercontrols and angularjs

Well I think your are looking into the wrong direction angularJs isn't similar to knockoutJS probably both of them have double binding, but definitely they are very different.
Angular is a Single page application that's built mostly for CRUD's applications, the typical architecture is to use a restFul web service behind angular (which is going to be your front end) and they communicate using JSON as the communitacion format, been that said, I'd suggest to move on ASP.NET web API and angular
this video could be helpful for you to get the whole picture.
EDIT:
Unfortunately i don't have an specific example for your scenario but I've found a couple of articles that may help you on your journey.
A good example of how to use knockout.js and asp.net definetelly you can look at it and take that as a good source for learn it and apply it to your case.
This is another example using a usercontrol with knockoutjs
take a look to this gibhub repo with and example of the proposed architecture

Related

ASP.NET Web Pages, WebForms or MVC?

I am thinking about using on of the technologies mentioned in the title but I can't decide which one would be the best for me. I jsut looked at asp.net to get an idea of each technology but I think I need a mix of MVC and WebForms, so that is why I am asking..
I want the MVC structure in the app itself and in the URLs
I want easily create a gridview with paging and sorting and easily map it to an SQL Database
I want to style everything easily via CSS
After I looked at asp.net I think MVC3 would be great for me but I need this in combination with WebForms, as I saw the DataGridView Control will be the best choice for my gridview.
Does someone give me some ideas what the best might be for me ?
After a long time using PHP and HTML/JS I hate it to doe every little step and using precreated Controls I only need to map to a database and customize via css would be a great enhancement to speed development things up!
Thanks!
In my opinion you should opt for MVC 3 approach (given most of your points mentioned) combined with jQuery DataTables. This gives you a best of both worlds - a great data visualiser and all the advantages of MVC 3.
DataTables
http://datatables.net/
DataTables ASP.NET MVC 3 Tutorial on CodeProject
http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part
Additionally if you didn't want to use the jQuery Data Tables you could look into MVC 3 Web grid which is the built in DataGridView equivalent for MVC:
http://msdn.microsoft.com/en-us/magazine/hh288075.aspx
You can use MVC, with aspx, Where you can also use the webforms features that you wished for.
I know there can be a flame war about this, people would suggest different suggestions.
Go for what you want.
All of what you need is possible easily in ASP.NET MVC.

ASP.NET MVC3 Single page design suggestion

I would like to create an UI for my app ( current I've an UI in WPF ) and I like the "Single Page Application" paradigma. I'm a little stuck on how to start implementing it: I don't mind about SEO, mine is an enterprise application. Do I need to use something like sammy.js, backbone.js and so on? I'm really new to Web GUI developement and I'm a little consfused: why can't just use jquery calls to drive my single page DOM? Is there some drawbacks about this strategy?
Checkout this series of blog posts by John Papa this could give you a jump start...
http://johnpapa.net/building-single-page-apps-with-knockout-jquery-and-web-api-ndash-the-story-begins
http://johnpapa.net/spapost2
http://johnpapa.net/spapost3
http://johnpapa.net/spapost4
http://johnpapa.net/spapost5
Hope this helps
First of all, you can do your single page application with jquery only. However, you will be writing a lot of plumbing code to handle interactions between the different parts of your UI. Which is not the most interesting part of the developmnent process, especially if frameworks do it nicely for you.
You should have a look at this question : https://stackoverflow.com/questions/5112899/knockout-js-vs-backbone-js-vs, and decide between knockout and backbone.
For implementing a simple master-detail UI (left column for listing items, right column for display, jquery popups for more details or editing), I chose knockout, and was not disappointed.
The learning curve is not as steep as backbone's, and coming from a WPF MVVM app it was easy to understand the development paradigm.
I chose ASP.NET MVC to serve the html templates using ViewResults, and after that everything went through JSON.
Knockout made this easy because of it's client side databinding capabilities. Then, when posting data back, MVC modelbinding made server side binding easy as well.
You could use just jQuery but it can soon become very hard to manage if not designed very carefully. Take a look at knockout.js which is mvvm it's great for managing state and reacting to events.
If you develop SPA then your best choice would be knockout.js+MVC+Ajax/jQuery

Why can't I use server controls in ASP.net MVC?

I'm getting ready to be responsible for leading the development of a small ASP.net MVC application. This is my first time creating an MVC application, so I am excited!
I've carefully read over the documentation and I feel like I have the general idea of how MVC works. However, if I understand correctly, server controls (like GridView, for instance) are not part of MVC.
My question is: Why? At my development shop, I'm so used to using controls like GridView and the MS Chart Controls that I'm almost at a complete loss as to developing without them. It seems almost like starting over.
Why are the server controls unavailable? How does Microsoft expect me to work without them? What are the alternatives?
My question is: Why?
Because most of them depend on things like ViewState and the Postback models which are part of the classic WebForms model and no longer exist in ASP.NET MVC. Those server side controls rely on events that will perform postbacks to the server persisting their state in hidden fields (ViewState). In ASP.NET MVC you no longer work with events such as Button1_Click. In ASP.NET MVC you work with a Model, a Controller and View. The Controller is responsible for receiving user requests, querying the Model, translating the results into a view model and passing this view model to the View whose responsibility is to display it under some form.
In ASP.NET MVC there are HTML helpers that could be used to generate some reusable HTML fragments between views. You may take a look for example at the Telerik ASP.NET MVC suite of such helpers. They call them controls but they have nothing to do with classic WebForms server side controls. They are just HTML helpers.
Basically classic WebForms are a leaky abstraction of the web. What Microsoft did back in the time when they designed this framework was to bring existing Windows developer skills to the web which was getting more and more momentum. But since the web was still a new technology that most developers weren't yet familiar with, they created this abstraction to hide away the way that the www works. Those developers were accustomed to drag and dropping controls on their Windows Forms, double clicking on buttons that was generating some code for them in which they put their data access logic and so on. This model was transposed to web application development thanks to WebForms. The HTTP protocol was successfully hidden behind this abstraction called WebForms. For example you don't need to know HTML, nor Javascript, not even CSS in order to create a website using WebForms which is really great because the framework abstracts all those things for you. Unfortunately by doing so it prevents you from easily utilizing the full power of lower level web technologies which some people might need when developing web applications.
What ASP.NET MVC does is basically remove this leaky abstraction and bring the www to the developers the way it was intended to be by its creators. ASP.NET MVC is not mature enough compared to classic WebForms so you cannot expect to find the same range of available controls and widgets but things are slowly shifting.
I would recommend you start here with ASP.NET MVC: http://asp.net/mvc. Go ahead, watch the videos, play around with the samples and see if ASP.NET MVC is for you or not. And of course if you encounter some specific difficulty or question don't hesitate to come back here and ask it.
I'm so used to using controls like GridView and the MS Chart Controls that I'm almost at a complete loss as to developing without them. It seems almost like starting over.
In this case, starting over is good.
I've gone through a similar journey. If straight HTML scares you, try working with the System.Web.UI.HtmlControls namespace. This will allow you access to standard HTML controls, but you'll still have the comfort of turning them into server controls if you need to (either by specifying the runat="server" attribute, or by converting them into equivalent ASP.NET controls.
In addition to Darin's answer, there's another problem with ASP.NET: you're bound to Microsoft's view of the web. That GridView you love? It's generating bad HTML. The Paging controls it provides? Even worse. Even if you know very little about HTML compliance, nested tables should give you the chills. In a way, everyone who uses a GridView is lucky that legacy web supported by Microsoft (and to a lesser degree, Google and Mozilla) came from such a god awful starting point.
Finally, to summarize: my suggestion is that you try to rewrite your pages or develop new web applications (as best as you can) using HtmlControls only. You'll probably have to learn some JavaScript/jQuery, and might have to venture into the world of AJAX to make your controls operate the way you want them to.
Use this as a stepping stone into the world of MVC. You won't use the same technologies (and may drop a lot of JavaScript/jQuery), but it will help you change the way you think about web development in much smaller, and perhaps easier-to-absorb chunks.
Ultimately, however much you like your ASP.NET controls, you'll have a much greater degree of freedom, and you'll also be developing websites that make use of newer technologies, which will provide added value to your websites.
At the core of this is Model View Controller (MVC) which promotes decoupling. The idea is that you feed your View (web page) a Model with all the data that it needs to be rendered. Server controls are tightly coupled. There is no concept of state in MVC or 'should' be no concept anyways.
That's kind of the point of MVC. It takes away the high level of UI abstraction that server controls provided and leaves you with html and javascript. (It also adds some really cool model binding features)
I am new to MVC and have found using Partial Views to be similar in creating small, reusable UI elements that do not fit into the _Layout. For example, sliders, slideshows, navigation, featured sections although you can use #section for this I find partial views to be more beneficial. This concept enables me to create reusable libraries that I can switch out easily and use in other projects. To me this is similar to controls, although there is a debate both for and against this analogy.

asp.net MVC GridView Alternatives for Displaying Data

I'm just getting started with ASP.NET MVC and am going through the NerdDinner tutorial. As I'm going through I'm trying to apply what I see with how I will develop my site. I have experience with WinForms and much of what I'm wanting to do is display large amounts of data contained in a database.
I have used DataGridView along with DataSets and DataTable accessing SQLite databases. Going through the NerdDinner tut I see mainly access to SQL Server through Linq to SQL and generating HTML tables rather than using ASP.NET Web UI Components such as GridView.
I like most of the functions and look that the Web UI Components can bring, but I'm not sure if they are necessary. How do you all decide when displaying lots of data from databases what display components to use?
By experience with MVC and ASP .Net Control, your better not user control in a ASP Web form application.
The point is that they work with view state that is against the pattern of MVC.
In the case of your DataGridView what I would do is to loop through the list with a foreach and output a table row.
Phil Haack has a good post of using the jQuery Grid plugin with MVC to create a more "out of the box" grid solution like what you would be used to with the ASP.NET controls you mention.
MvcContrib has a lot of great things to aid with ASP.NET MVC development. In this case the Grid would help you a lot. I've used it in the past and found it to be pretty slick.
If you're using jQuery as well, this article talks about integrating it with the jQuery datable--makes paging and sorting essentially no-effort/painless.

Best way to learn Ext JS for use with ASP.NET?

I have very basic knowledge of Javascript and now I am looking forward to learn Ext JS and implement in in my ASP.NET application.
If anyone can guide me on how to start and which book I should follow, I'd be thankful.
Nor sure if it is the quickest approach, but all I did (as well as another developer that was working with me) was review the ExtJS documentation and samples gallery (and viewing their source).
One big issue to watch out for when using ExtJS with ASP.NET is that when using BorderLayout you will go crazy trying to figure out why Postbacks no longer work. There is a workaround though.
Another ASP.NET gotcha is that if you use ExtJS to talk with ASP.NET web services (or WCF) you have to do some special things to get it to work (adorn your webmethod with special attributes, or add some things to web.config, etc).
Those were the only two gotchas I can recall, other than just learning and getting the hang of ExtJS itself.

Resources