PDA

View Full Version : [CLOSED] [MVC] ASP.net MVC



googleninja
Apr 02, 2008, 5:12 PM
Hey guys

Just want to say I am very impressed with what I have seen so far of coolite.

I was just recently digging into ASP MVC, and currently the big deal breaker is that for rich controls, you basically have to write the javascript yourself, or learn a js ui library like Ext. The various big vendors have either said no, or that they just don't know when it comes to MVC support.

Even though you aren't fully off the ground yet, IMO you have the closest thing to controls that would be usable on the MVC framework. I know it would take work, but it might be worth looking into.

geoffrey.mcgill
Apr 02, 2008, 5:29 PM
Hi googlemania,

Thanks for the feedback. We really appreciate your interest in our project.

We're tinkering with using the Coolite controls in MVC and will do our best to support the framework.

I would be very interested in hearing from anyone that would like to test the Coolite controls with the MS MVC framework. Send and email to geoff [at] coolite [dot] com stateing your interest and I will do my best to keep you up to date with our progress.

rodiniz
Apr 29, 2008, 3:57 PM
Hy geoffrey ..coolite will not work with aps.net mvc ...no controls will work because the mvc framwork removes the runat server from the form and that makes evry control unusable.

googleninja
Apr 29, 2008, 4:04 PM
Controls will work, they just don't really have a life cycle. since coolite is wrapper around pure js, it doesn't (or shouldn't anyways) be tied that tightly to asp specific abstractions like the page lifecycle or viewstate.

geoffrey.mcgill
Apr 29, 2008, 4:11 PM
Actually I have pretty much everything working perfectly. Especially any Container control (Panel, Window, etc) and the new Layout controls. We're working on the FormPanel and some of the guts of the existing Form (TextBox, Calendar, etc) controls will have to change, but overall, supporting MVC will not be a problem. I don't think the existing Form controls will support MVC for the 0.5 release, but they will shortly.

geoffrey.mcgill
Jun 06, 2008, 1:07 AM
If anyone is still following this thread and developing with the MVC framework, I would love to get your feedback. The 0.5 build has been released (http://www.ext.net/download/). I didn't get much chance to go deep with Coolite and MVC, but my preliminary demo's all worked well (shockingly well actually). There were a few things I did not expect to work, but amazingly they did, straight "out of the box".

I need a few people to play around with Coolite + MVC and get us some feedback.

One area I'm particularily interested in is testing the Form controls. They *should* now work.

googleninja
Jun 06, 2008, 11:09 AM
I'm kinda in a real busy place right now, but I'll check it out ASAP. Really excited about the whole MVC thing, finally a framework from ms that you don't have to fight with to write well archetected software

jxvalenz
Jun 07, 2008, 12:02 AM
I'm developing an application using MVC and Coolite. Rodiniz is right on MVC removing the <form> tag from views. I created a view using the ViewPort control and at first it would not load up. It would throw an exception confirming the lack of the form tag. I manually added the form tag around the script manager and viewport control and they worked fine.

What I'm facing now is that if I'm using Master Pages and the view is an MVC Content View instead of a standard MVC View then the Coolite controls will not work even with the form tag around them. I don't get an exception this time, but they just won't load at all.

geoffrey.mcgill
Jun 07, 2008, 12:13 AM
ok, let me take another crack at this using the latest MVC preview 3 release. I have a demo running with exactly what you describe - ViewPort in MasterPage running with MVC - and it works great.

I'm just about to release a new build, so if any revisions are required, they will be included in the new build.

jxvalenz
Jun 07, 2008, 1:59 AM
I have it working with master pages now. I was doing something wrong in a javascript file before. I did have to add the <form> tag though.

Thanks

- Juan

geoffrey.mcgill
Jun 07, 2008, 2:12 AM
Hi Juan,

I found the bug which is causing the <form> to be required. If you're building from the source files, just change the following line (~ 241) in WebControl.cs...

Old


return ReflectionUtils.IsTypeOf(this.Page, "System.Web.Mvc");

New


return ReflectionUtils.IsTypeOf(this.Page, "System.Web.Mvc.ViewPage");

I'm also running into a problem with the URL rewritting for ext-all.js. I'm trying to track down the problem, but changing the CleanResourceUrl property on ScriptManger to "false" will render out the ugly /WebResource.axd urls, temporarily fixing the problem.

Example


<ext:ScriptManager ID="ScriptManager1" runat="server" CleanResourceUrl="false" />

I also found a bug in <ext:Window> if it's not placed inside a <form>, although this one should be an easy fix. The renderTo property is just being set to "Ext.getBody()" - wrapped in "quotes", but should be rendered as a raw value - without "quotes".

These bugs will all be fixed and available in the next 0.5.1 release, which I'm going to publish asap.

jxvalenz
Jun 07, 2008, 1:40 PM
Thanks Geoffrey, that did it.

By the way, thanks for putting this wonderful toolkit out. You have no idea how long I've been waiting for this. The amount of javascript code it saves me is unbelievable. I'll be posting my findings on the MVC side of things as I go.

geoffrey.mcgill
Jun 09, 2008, 7:43 AM
I just published a new build (v0.5.1) (http://www.ext.net/download/), which includes several enhancements for Microsoft MVC support.

After upgrading to MVC Preview 3, some of the JavaScript files and paths to the Icon files were not rendering correctly. The correct paths were being rendered in html, but the files were just not being served up properly. This threw me for a while until it finally occurred that the new Preview 3 MVC Routing engine was hijacking the requests.

With the Coolite Toolkit, by default, the file path rendered in html for any embedded resource file (.js, .css, images) are cleaned to create a presentable (hand-coded'ish) url.

Example


<script type="text/javascript" src="/extjs/ext-all-js/coolite.axd"></script>

Now, the problem happens because the above url pattern maps with the same (or similar) pattern as the default MVC "{controller}/{action}/{id}" MapRoute.

Example


routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);

The Routing engine ignores the .axd and thinks the remainder is a "controller/action/id" route.

MVC Preview 3 introduced the IgnoreRoute Collection. With the default MVC project, the following .axd IgnoreRoute is set.

Example


routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

At first I thought that might trap the coolite.axd paths, but after some digging around I figured out that you have to set an explicit "3 part" IgnoreRoute.

Example


routes.IgnoreRoute("{exclude}/{coolite}/coolite.axd");

If you include a MapRoute with 4 parts , example, "{controller}/{action}/{anotherthing}/{id}/", then you'll have to include another explicit 4 part coolite IgnoreRoute.

Example


routes.IgnoreRoute("{exclude}/{evenmore}/{coolite}/coolite.axd");

You can also set the CleanResourceUrl property to "false", which will render the ugly webresource.axd paths for all embedded resources, but your code gets gross and you loose default gzip encoding and caching.

The following lists other MVC related enhancements for v0.5.1:

Fixed the bug which required a <form> for most controls. Now, by default, a <form> should not be required for any control. This can also be forced by setting the StateProvider to "None", although is not required.

Example


<ext:ScriptManager runat="server" StateProvider="None" /> Improved MasterPage design-time support. Opening a .aspx Page which links to a a MasterPage should now render just as if the <ext:ScriptManager> was on the .aspx Page.
Cleaned up the _Containers that were rendered to the Page. Now only containers/html which are absolutely required will be rendered. Under some circumstances this removes 90%+ of the html that was previously rendered to the page. [high-five]!
I also built in some more control over how the Control ID's and ClientID's will/can get rendered to the page. The client-side ID's are currently getting renamed because of the INamingContainer inheritance of MasterPage, which is not in the spirit of MVC. For version 0.6 I think we can support absolute naming. What you set as an ID will be rendered exactly to the client. This may cause ID collisions, but will be left up to the developer to handle.

Please let me know if you run into any bugs and I'll do my best to help out.

I'm also *really* looking for feedback and comments re: our MVC support. If you have any suggestions or a "wish list", just let me know.

Hope this helps.

jxvalenz
Jun 10, 2008, 12:55 AM
You just saved my sanity! I was going insane trying to figure out what was wrong. I just upgraded my application to MVC Preview 3 yesterday and everything stopped working all of a sudden. It was due to the changes in the routing engine that you mentioned.

Thanks Geoffrey.

jxvalenz
Jun 20, 2008, 1:58 AM
Geoffrey,

After upgrading to Coolite 0.5.2, I get this exception when running my application:

"Control 'ctl00_MainContentPlaceHolder_Panel1' of type 'Panel' must be placed inside a form tag with runat=server."

The exception happens on line 526 on WebControl.cs.

I'm using MVC with Master Pages. Any ideas?

Thanks

- Juan

geoffrey.mcgill
Jun 20, 2008, 2:02 AM
Hi Juan,

Try setting the StateProvider property on the ScriptManager to "None".

Example


<ext:ScriptManager runat="server" StateProvider="None" />

This should have been automatically handled, so I'll run a few tests and try to determine what changed.

Thanks for posting the bug.

geoffrey.mcgill
Jun 20, 2008, 8:38 AM
Hi Juan,

Ok, I fixed the bug. As a temp solution, please set the StateProvider to "None". In the next build (or SVN), this will be handled automatically.


<ext:ScriptManager runat="server" StateProvider="None" />

Hope this helps.

geoffrey.mcgill
Jun 23, 2008, 9:03 AM
Version 0.5.3 has been release which includes the fix for the StateProvider bug above.

http://www.ext.net/download/

Hope this helps.

jxvalenz
Jun 24, 2008, 1:01 AM
Thanks Geoffrey. It is working for me now.

- Juan

jxvalenz
Jul 04, 2008, 12:31 AM
Geoffrey,

I think I might have hit a major wall. I'm having the exact same issue as described in this post: http://forums.asp.net/t/1275301.aspx

My application is also based on the complex layout. I'm using the coolite viewport control.
Is there a way to tell the viewport control to use "scripts = true"?

The behavior I'm experiencing is this:
* The viewport loads a tree of options in the West region.
* I click an option and a Tab is opened in the Central region. So far so good...
* Here comes the problem: the tab calls a controller that returns a View Page and any javascript in this view is not executed. I replaced the view with a View User Control and the same results.

Any ideas?

Thanks

-Juan

geoffrey.mcgill
Jul 04, 2008, 2:26 AM
Hi Juan,

Are you loading the Tab with server-side or client-side code?

On the server-side I think you should be able to call the .Load method on the Tab and pass in a LoadConfig object with Scripts = true set.

Example


LoadConfig config = new LoadConfig("/controller/action/55");
config.Scripts = true;
this.Tab1.Load(config);


Hope this helps.

jxvalenz
Jul 04, 2008, 3:31 PM
Hi Geoffrey,

I'm loading the tabs on the client side using pure ExtJs. The reason I'm not using the Coolite TabPanel is that I needed to use the additional plugins on the tab and I could not figure out how to do it in coolite.

Is there a way I can resolve this?

Thanks for your help.

- Juan

geoffrey.mcgill
Jul 04, 2008, 4:07 PM
What do you mean by "additional plugins on the tab"? Can provide a link if this is a UX extension?

jxvalenz
Jul 04, 2008, 4:56 PM
Geoffrey,

This is what I mean by additional plugins on the tabs:



var tabs = new Ext.TabPanel({
renderTo:'mainTabs',
border: true,
plugins: new Ext.ux.TabCloseMenu(),
...


Is there a way to do this within Coolite?

Thanks

- Juan

geoffrey.mcgill
Jul 05, 2008, 3:15 AM
Hi Juan,

Support for Plugins has been added. See Release Notes Revision #96 (line item #11).

http://forums.ext.net/showthread.php?threadid=849-12-1.aspx

The Plugins property and UX sample Plugin is available via SVN and will be publicly available with the release of v0.6.0.

Hope this helps.

geoffrey.mcgill
Jul 05, 2008, 4:00 AM
I uploaded a Plugin sample to the Sandbox, see http://sandbox.ext.net/Plugins/TabCloseMenu.aspx

Just right-click on any Tab to trigger the TabCloseMenu plugin which displays a Context Menu with options to close "this" tab or "other" tabs.

In the "Source" Window, the UX Plugin code is available which demonstrates how to create a custom user Plugin control ( <ux:TabCloseMenu> ).

Notice how only Tabs marked as "Closeable" can be closed by the TabCloseMenu Context Menu.

The .aspx source demonstrates three options for setting the same Plugin, although only one is required.

Hope this helps.

jxvalenz
Jul 05, 2008, 5:15 PM
Geoffrey,

Thanks for your quick response. This is exactly what I need. I guess I'll have to wait until release 0.6.0 comes out...

- Juan