I barely got into ASP.Net webforms when MVC came out, and now I'm ready to try it out. But, I want to clarify something to be sure I understand the View coding in ASP.Net MVC...
I've heard that you must hand-code all the HTML in the View layouts, and that you cannot use server controls for this. Now, I like the way you can use the asp:ListView to present a list of data in webforms, and I've made heavy use of the SelectedItemTemplate and the concept of SelectedItem as a whole. So, I fear a big headache in having have to handle all that output yourself, versus letting the server controls do it. Same goes for DataGridView and the Select, Edit, Delete commadds that come with that server control.
In a particular case I am brainstorming over, I have Customer names displayed in a asp:ListView, and then when you click on a Customer name, it uses the SelectedItemTemplate that expands within the ListView to highlight that row and show more details about that particular Customer (right in the ListView).
I'd love to see some sample asp.Net MVC view code that shows how to handle this commone UI presentation technique.
there are some good GridView for ASP.NET MVC
http://www.codeproject.com/KB/aspnet/MVCFlexigrid.aspx
http://www.reconstrukt.com/ingrid/example1.html
Related
We've been working on web solutions for over past 9+ years and just like many of you, we've migrated from the legacy ASP to ASP.Net, MVC, knockoutjs and so on. jQuery played a keyrole and now it seems its the age of MVVM libraries like KO with declarative data binding based approach.
I'll stop here and ask for expert opinions on our two requirements -
An editable grid with inbuilt sorting, paging and basic search. And if possible a grid capable of handling its own editable dialog (i.e. like datatables.net - but its paid)
Is there a way to take the declarative binding to the next level and auto-generate forms backed with knockoutjs like data-binding technology.
I believe no need to mention that we're working in ASP.Net v4.0+ and MVC. Most of our forms are backed by one or more table(s) and we can easily manage the backend CRUD operations once the correct actions are triggered from front end and we can have requests serving JSON as and when requested.
PS: We don't need the old school approachs like the #Html.EditorFor in MVC.
I have an existing usercontrol "BigForm.ascx":
<%# Control
Language="C#" AutoEventWireup="true"
CodeFile="BigForm.ascx.cs" Inherits="BigForm" %>
<asp:Panel runat="server" DefaultButton="btnSubmit">
<%--SUPER COMPLICATED FORM--%>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</asp:Panel>
BigForm.ascx is very complicated - it dynamically adds subcontrols to placeholders, it encapsulates a whole lot of business logic, the markup is heavily customized, etc.
I can add BigForm.ascx to Kentico using the "User Control" web part and it works perfectly.
But if I convert BigForm.ascx to a "proper" web part - by inheriting from CMSAbstractWebPart instead of from UserControl - postbacks don't fire. I'll click on the submit button and nothing happens.
I've seen the Kentico doco on designing forms using the form builder, but this usercontrol already works perfectly, and I suspect that it's far too complicated to build with a WYSIWIG. Not to mention that I strongly prefer building forms using Visual Studio.
My understanding is that using a web part is the "correct" thing to do with Kentico, and that doing so will let users specify properties on that Web Part (e.g. if we'd like to translate the form in future - we could put a "First Name label text" on the web part and the user could put in "Vorname" instead of "First name").
What do I need to do to convert a working usercontrol into a Kentico web part?
First off, if it's not broke then don't fix it, unless you're looking or required to have more diversity in your control. If your complex control works well using the User Control web part AND you're not up for using Kentico's out of the box functionality, then I'd suggest sticking with the User Control web part, because it works.
If you are interested in learning more about how to create web parts, how their life cycle differs from a standard user control and making your control more dynamic, then read this documentation.
One of the big differences you'll notice is the Page_Load event is there but isn't used much. The OnContentLoaded event is used, which happens before the standard asp.net OnInit event. This is where you set all your property values and load your data. Button events do happen just like within standard Forms, after the Page_Load event. Just like standard asp.net, any dynamically loaded controls need to be reloaded/created on every post back. Controls which are holding data need to be bound on each post back as well. This doesn't mean you have to retrieve the data again because the caching engine is awesome, it means the control has to have a DataSet assigned to it and not conditionally loaded. Take a look at this example on how to load cached data in Kentico.
Regarding building forms, yes it works well within Visual Studio, no disagreements there, although when you have to create and handle all your CRUD actions manually vs. simply catching those events, either within your web part or globally, it makes it much easier, more dynamic, more robust and faster to build.
As a long time Kentico developer, it does take a bit to get out of the mindset that you need to develop everything from the ground up. In many cases the tool you're using, Kentico in this instance, already have standard controls created for what you're doing or needing to do. OR if you have a complex solution, breaking it down into smaller pieces and create smaller user controls and dynamically load those into your web part works very well.
Good luck with your endeavors!
Form documentation
Working with Form Data using API
Is it possible to do a KendoUI mobile project, using ASP.net mvc? Watching the introduction on Pluralsight, I'm sort of confused. As an example, KendoUI Mobile uses something like this to navigate:
<a href="#someView" data-role="button">Go to some view</button>
When rendering views through RenderBody in my main layout, will I have to specify this view as a mobile view, or does the application defined in my main layout pick up on this?
So, I guess my question is this; Has anyone got any experience on this combination and, if so, could you provide some resources as to where this combination is being used?
I figured this on out. Seems to be a few projects out there using this combination. One example is this project: KendoUI mobile task manager
That being said, I'll try to play around and tweak the framework to my needs.
The answer is Yes. I was searching for the same answers, and found this resource very helpful, using MVC4, with detailed explanations:
Single Page App using MVC and Kendo Mobile
When searching for references and tutorials, what is not immediately clear is that Kendo UI Mobile is a different setup from Kendo UI. As WhizKid points out it is a single page application, and all your data must go through AJAX.
If you have not used them before, you will probably need to learn Kendo's MVVM and datasources. You must decide what sort of interface you will use for data exchange (eg. WebApi, OData) and fix the routing.
The reason I am going this way is because Kendo comes with good looks, and MVC can help me with localization.
With using MVC3, I am hoping for a decent wizard multistep approach. I need to have previous, next , save buttons. Both Next and Save will be saving data to the database (more of holding staging table), yet I don't want to make the navigation a nightmare to code and manage. I use to do this stuff with webforms, but I am hoping for a good solution with mvc3. I really don't want sessions or cookies. I did notice in the Apress book "Pro ASP.NET MVC 2" by Steven Sanderson. On page 478 he says "There are unlimited ways in which you could accomplish this....." (regarding a wizard multistep form).
He mentions collecting and preserving data with Microsoft MVC Futures dll download, and then serializing hidden input tags.
I wanted to hear back from some experts out there on this approach vs. other approaches/solutions.
Thanks in advance.
hope this post will give you some start
You can have a look of the simple component MVCWizard.Wizard available on NuGet. The WizardController allows you to create a wizard using partial view. There is also the AutoWizardController that renders the entire wizard in a single view. All these components operate with the session to store the model state. You can find example of MVCWizard on NuGet.
I'm working in a Banking Online Platform written in WebForms and I'm wondering if the same could or should be written in MVC.
I've read a lot on MVC but i didn't tried yet but i must ask a question for the experts.
Every transaction has a 3 Stage Process where the users input the data, review the data and gets a 3rd step where get's the confirmation. I currently have 40+ processes like this. The way i do it? Single ASPX with MultiView.
How can i do the same in MVC? Would i have 40+ x 3 Views (120+ aspx) ?
Thank U all.
The same can be achieved in MVC by using partial views.
MVC has full control over the rendered HTML and JavaScript frameworks is much easier to implement. It is also a lot more easier to write unit tests.
It is also 'lighter' in the sense that it does not have any View State events (which is the thing that makes Web Forms big when working with big data)