|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Dabbling in MVC
I'm looking to get deeper into MVC and began dabbling a bit. Am I correct in thinking that to access a server control you choose "convert to web application" which creates the designer files? Is there any downside to taking this step?
Of course adding a server control to an MVC app adds the viewstate to the page. Is that inappropriate for an MVC app? |
|
|
|
|
|
#2 |
|
Community Advisor
![]() ![]() Join Date: May 2003
Location: Washington, DC
Posts: 9,134
|
MVC apps really don't do server controls--it doesn't have the framework bits (like ViewState and page events) they ride upon.
|
|
|
|
|
|
#3 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
Convert to web app and then add a <form runat="server"> and you get viewstate. Is that a mortal sin in the MVC arena? ![]() |
|
|
|
|
|
|
#4 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2002
Posts: 1,013
|
Mortal sin?
NAWA, something I've learned from my time here is that if it works, and satisfies a requirement, do it. Patterns, best practices, and all that stuff don't amount to a hill of beans if you cannot do what you need to do. Just my two cents. |
|
|
|
|
|
#5 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
![]() |
|
|
|
|
|
|
#6 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2002
Posts: 1,013
|
There's a much better way to make lists anyway. Use the following html helper:
Csharp Code:
Put it in a public static class, and then in your page: Csharp Code:
Where the partial (mvc version of a control) is: <li><%=Model.Field%></li> Anyway, take a look at how partials and html extensions work, and I think you'll find that you'll be able to not only do what you want, but all without viewstate, and WebForm oddities. |
|
|
|
|
|
#7 |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Well, that is mighty interesting. Any gotchas in nesting lists?
I actually do make rather heavy use of the calendar control. That's still an issue. |
|
|
|
|
|
#8 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2002
Posts: 1,013
|
Using the same technique, you could roll your own extremely quickly. Image a single line in your page...
<% Html.RenderCalender(Model.Year); %> Where your helpers looks like this: public static string RenderCalendar(this HtmlHelper helper, Year year); public static string RenderMonth(this HtmlHelper helper, Month month); public static string RenderWeek(this HtmlHelper helper, Week week); public static string RenderDay(this HtmlHelper helper, Day day); Based on a Year having many Months, having many Weeks, having many Days... Just have each loop and call the next, starting new rows when needed, and other standard calendar things. You could even change the first one to accept some flags for mini-calendars and paging... public static string RenderCalendar(this HtmlHelper helper, Year year, bool showMini, bool allowPaging); Good luck. |
|
|
|
|
|
#9 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
![]() Edit - it doesn't really look all that complicated: http://www.codeproject.com/KB/aspnet...-calendar.aspx Hmmm... interesting. |
|
|
|
|
|
|
#10 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Dec 2002
Posts: 1,013
|
Yes, by the title alone (ASP.NET MVC Calendar by extending the HtmlHelper) I can see it is an example of exactly what I was talking about. Two things to note however:
1) Unless his package offers code and ascx templates, and not just a binary, then your level of customization will go down. 2) In the sections where he uses in-line code nuggets to initialize "allPosts" and "dateArray"...just don't do that. Use a highly typed View and pass in a thin presentation class that holds any pre-prepared data you may need. In your controller action: // set allPosts here // set dateArray here return View(new ShowCalendarPresentation(){ AllPosts = allPosts, DateArray = dateArray }); |
|
|
|
|
|
#11 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
I'm sure that was just for quick demonstration purposes. Duly noted. I intended to get into MVC earlier this year but I had to go make money instead. I've got so much to learn. |
|
|
|
|
|
|
#12 |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Now that I look at that MVC calendar I like it probably even better than the server control. It's easily modified and gives me ideas to replace other things I thought necessary.
|
|
|
|
|
|
#13 |
|
Community Advisor
![]() ![]() Join Date: May 2003
Location: Washington, DC
Posts: 9,134
|
For 99% of controls one used to use, best bet is to look for jquery plugins. For example, there are a bunch of really slick calendar controls that one can choose from for most desired effects.
|
|
|
|
|
|
#14 |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
I see. There are some rather nice calendar plugins for jQuery. How would I handle a fallback if javascript is disabled? The event calendar is a major part of most of my sites and I'm not sure it should be scripted on the client side.
|
|
|
|
|
|
#15 |
|
Community Advisor
![]() ![]() Join Date: May 2003
Location: Washington, DC
Posts: 9,134
|
They tend to grow out of text boxes, so, at the end of the day, a user should be able to input a date/time value and it will work.
|
|
|
|
|
|
#16 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
You mean the calendar extender in the AjaxToolkit, right?I mean an event calendar like this: http://newcastlechurchofChrist.com/calendar It uses an <asp:Calendar> and the new version (not yet uploaded) uses an <asp:ListView> for the event list below the calendar. It's a rather major part of the site, if you were logged in you'd see more events, birthdays, anniversaries and such. I don't know that I should leave it up to client side scripting even though I do like this: http://arshaw.com/fullcalendar/ |
|
|
|
|
|
|
#17 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
|
|
|
|
|
|
|
#18 | |
|
Community Advisor
![]() ![]() Join Date: May 2003
Location: Washington, DC
Posts: 9,134
|
Quote:
|
|
|
|
|
|
|
#19 | |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
Quote:
![]() After spending today with MVC, I'm starting to understand how the parts work together. It sure is a different way of looking at things. I think I like it. I wish I had VS 2008 Pro so I could dig into the tests (I have VS 2008 Standard). |
|
|
|
|
|
|
#20 |
|
Community Advisor
![]() ![]() Join Date: May 2003
Location: Washington, DC
Posts: 9,134
|
That shouldn't stop you--just use nUnit or mbUnit, both of which feature their own test runners. And make sure to grab TestDriven.NET to tie it all together.
|
|
|
|
|
|
#21 |
|
Regular
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2007
Location: Pennsyltucky
Posts: 675
|
|
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 19:20.









You mean the calendar extender in the AjaxToolkit, right?


Linear Mode
