Closed MisterJames closed 10 years ago
Where would the HtmlHelpers go? The CollidR project does not have a dependency on System.Web.Mvc. Does it make sense to add a CollidR.Mvc project for the helpers?
Yeah, that's good. I think that's forward thinking, too, as far as thinking other clients. Like WinForms :)
I left out the
<script src="~/Scripts/CollidR.js"></script>
portion from the generated code for a few reasons: a) the ~ part does not get resolved when it is returned from an HTML Helper b) the script might already be included in the shared layout c) not sure it's a good idea to assume what folder CollidR.js is located
So...maybe we should include that by default and have an overload that mutes the script tag? That way it works with one line of code, but if you need to control when/where it gets written you can.
I will see if I can get the path to resolve then. It's a trickier problem than I thought it would be.
Gotcha. We could keep it simple to start...the default path (from the NuGet install) is going to be as above. If they need to change it, maybe we do an overload for the path of the script?
I think at this point we don't need to resolve the path, just assume it's okay. Add the override to mute it, then they can add it manually if they like (to a layout, for example).
If we put src="/Scripts/CollidR.js", and the application is installed in a virtual directory in IIS (eg. http://localhost/MyApp), then the browser will not find CollidR.js. It will try to find it at http://localhost/Scripts/CollidR.js.
The ~ solves that problem normally, but not for strings that are returned from the HTML Helper
Gotcha. Okay...I'll leave it to you for implementation here then, either way (assuming or full resolution) is okay with me for now.
Okay, figured out a way to do it
Now that I committed the changes, I am wondering if the helper method should be renamed RegisterCollidRFor() since it is model bound. This would be consistent with the EditorFor / Editor convention in the built in MVC helpers.
Agreed, that's probably a good call. Just commit the update for the rename before you merge the pull request and it will be included.
Closed with #23
Can leverage reflection/generics/etc. to find the name of the model and possibly the ID based on primary key, or have it provided through the method call.
This would allow for auto generation of the following:
With a line of code like: