Using qTip with ASP.NET MVC unobtrusive javascript validation - asp.net-mvc

on the new jQuery qTip page, there is a really awesome sample of using it with jQuery Unobtrusive Validation, which can be found here
In ASP.NET MVC 3.0, we have the unobtrusive validation as part of the view helpers. I was wondering if anyone knew how to implement this incredible thing in that, since I have not been able to.

This link is to an article describing how to integrate the jquery.validationEngine.js plugin with jquery.validate.js.
The line number references are slightly off, since they refer to older versions of jquery.validate.js. However, you can use the points referenced to insert the code to have qTip balloons pop-up or disappear, based on validation done by jquery.validate.js.

Related

add pagination control for asp.net mvc

I am new to asp.net MVC. I am trying to understand how to add pagination for a list of items using MVC without code for a view. I am using nunit testing to check whether pager option is tested or not
There is no built-in pagination for a vanilla MVC project -- you'll need to write one yourself or find something off the shelf.
See PagedList, which is also available on NuGet.

challenges in upgrading Bootstrap Themed ASP MVC site, how to upgrade bootstrap + keep previous CSS / #Helper / Transpiler

I've built an ASP MVC site and used bootstrap, Jquery, knockout and signalR, and inherited a mix of 3rd party MVC code integrated with controls like syncfusion. (I don't have a choice in this matter, company decision)
After coding the HTML helpers in the views,
I manually applied all the bootstrap styles took sometime and got it
to work. Now, with upgrade/changes to bootstrap (RC 3.1) I am finding
myself back to square one, hunting through the code and replacing it manually, lots of
changes. Can you please share a better way to transpile/emit/bind the
bootstrap CSS classes into the helpers (i.e. in an independent way of the
technology helper, whether its ASP HTML MVC helper, Syncfusion HTML
MVC helper, Rad or FluentBootStrap)
Please provide a solution/recommendation to apply bootstrap CSS to ASP MVC pages
That's easy to separate and maintain and CSS upgrade's Programmtically
or globally configurable/settable/applicable
I've been thinking extension classes might be a good option, but not sure how I can achieve this, if you've can show me how to get the custom bootstrap CSS bound so I can programatically apply it or globally,
Is there a transpiler or Razor Declaritve Helper (I know about the nuget package, I tried applying it, and it turned out to be more of a template, than declarative extension binding, and I couldnt use it with other libraries Syncfusion or DevExpress)
or some other way, I would greatly appreciate it.
Here is an example of what I do currently, with the Syncfusion library
#Html.Syncfusion().Menu("myMenu").AutoFormat((Skins)ViewData["Themes"]) - performance hog
or better option 2 below
http://mvc.syncfusion.com/demos/ui/tools/Menu/Appearance
#(Html.Syncfusion().Button("btnNormal")
.Text("Save")
.Width(100)
.Height(50)
.ContentType(ContentTypes.TextAndImage)
.ImageUrl(Url.Content("~/Content/Images/Button/icon_save.png"))
.CustomCSS("CustomCss_Button") )
-> I changed/upgraded manually to BootStrap RC 3.1, I changed this last part to the bootstrap
.CustomCSS("btn-default dropdown-toggle btn-primary"))
Not sure this would be helpful to you, but check out TwitterBootstrapMVC. Right now it supports v2.* of TwitterBootstrap, but the support for v3.* is being built.
Our answer is from the experience we are going through. Here is what we found,
currently, The twitter bootstrap MVC is your best option IMHO, we are moving everything to it and its free! Its probably better the broiler plate option.
The 3.0 upgrade is a big question for us as well, so this is
something Dmitry can clarify.
Also, auto creating type safe bootstrap HTML views/sections for models is another question.
In addition you will face challenges with custom controls, we have a OLAP BI client, which looks / or doesn't not have the same consistent look. Dmitry can you answer how to resolve this with twitterbootmvc
Dmitry, will the twitterbootstrap upgrade, auto upgrade to the 3.0 bootstrap or do we have do anything manually?
I just discovered that in visual studio you can for the precompile of RAZOR into HTML.
Can you add that as an option to fluent

MVC4 Project with HTML5 Semantic markup HtmlHelper.EditorFor uses HTML5 input types

I have a ASP.NET MVC4 project with HTML5 semantic markup enabled. When using #Html.EditorFor(m => m.MyDateTimeField) the output is an input with type="datetime". I want to be able to stop EditorFor from generating HTML5 markup. How can I do this?
This is only a problem in Opera at the moment because other browsers (as far as I know) don't support type="datetime". I have a jQuery datepicker on the field so in Opera I get both the jQuery datepicker and the browser datepicker.
I can fix using any of:
a. Use js to change the input type
b. Use Html.TextBoxFor(m => m.MyDateTimeField)
c. Use a custom editor template
d. Use modernizr to detect if datetime is supported and if so, don't use jQuery datapicker
The solution I want is to disable HTML5 generation in HtmlHelper.EditorFor. I want HtmlHelper.EditorFor to function the same way it would if I hadn't ticked the "html5 semandtic markup" checkbox on project creation.
EDIT:
After a bit more searching, I've come across the DataTypeAttribute which I can apply on my model fields to force them to be rendered as input type="text" rather than the html5 match. This is a potential fix, but it is less than ideal. Surely there must be a switch somewhere to turn off html5 in EditorFor (and equivalent helpers)?
A bit more info:
I have two projects. The first one was created with "Html5 semantic markup" on, the other without. The first one uses html5 input types when using EditorFor, the second does not. I need to stop the first project EditorFor behaving the way is does without removing the EditorFor. There must be a setting somewhere?
The problem is in one of the project the package references are not updated properly and hence you are seeing the html5 semantic rendered.
This issue happens when you upgrade the ASP.NET MVC beta version to RC and there two ways you could solve the problem either updating all the packages through Nuget or manually add the reference to assemblies.
The issue and solution is clearly explained by Scott here.
That's really feature that got introduced and wasn't documented (nasty...). Basically ASP.NET MVC 4 now defines internal editor templates for Date and DateTime. In ASP.NET 3 there were no templates so I personally had an EditorTemplate (in Views\Shared\EditorTemplates) called DateTime.cshtml which was handling all DateTime types and dealing with DataTypes.Date vs DataTypes.DateTime. Now you need to override both templates. Nasty.
Edit: Basically if you just want to not touch any of your existing code define two templates Date.cshtml and DateTime.cshtml which both have #Html.TextBoxFor(model => model) in Views\Shared\EditorTemplates\

Using ASP.NET MVC 3 **WITHOUT** jQuery

I need to write an application in ASP.NET MVC, but for corporate reasons I can't use jQuery. I have heard that you can "turn off" jQuery and that ASP.NET controls like TextBoxFor will fall back to using Microsoft's older JS libraries. But I haven't found any detailed information on how to do this.
Anyone have experience with this approach? Any pointers?
ASP.NET MVC does not require jQuery. The MVC3 project templates include it in _Layout.cshtml because many developers prefer it. You can remove it.
It does use jQuery Validation by default, however, but you can use the Microsoft Ajax MVC2 libraries instead.
If you remove jQuery scripts, you will be unable to use the jQuery/Unobtrusive MVC 3 validation.
Use the MS scripts and corresponding validation functionality instead:
_Layout.cshtml:
"~/Scripts/MicrosoftAjax.js"
"~/Scripts/MicrosoftMvcValidation.js"
That’s all.
By the way, why cannot you use the jQuery in your project?
It's all down to the adapters that you decide to include from the default script folders. If you don't want to use Jquery include the other adapter files.

Sitefinity 4 - MasterPages

I am running the trial version of Sitefinity 4 RTM.
The great thing about Sitefinity 3.x was that I could port my masterpages from an existing site and they would just work with Sitefinity: Sitefinity did not inject stuff into the pages, or the content blocks.
However, Sitefinity 4 seems to be injecting its own stuff (styles, etc) into the page that screw up my layouts.
Also, for example the Sitefinity ContentBlocks wrap their content in a tag.
Is there a way to stop this happening or would I have to rewrite my master pages and style sheets if using Sitefinity 4?
Other issues, eg, setting up a new site are great, but the above is a bit of a killer.
First, you'll probably want to post this to the Sitefinity forums. You'll get a lot more attention there.
--
However, here are a few thoughts:
Check out the Design and Skin settings for Sitefinity Widgets. By default, Sitefinity Widgets get associated with a Sitefinity Skin and some embedded stylesheets. By switching to a custom skin, you can define your own CSS.
Feel free to modify the templates being used by Sitefinity widgets. You can define your own HTML.
I'm doing a webinar next week (Real World Project Development with Sitefinity 4.0) that will touch on some of these things. For those visiting here later, the video can be found on Telerik.TV.
Good luck.
Once you integrate master page from an existing site, no need to add attribute block in the child page, provide only the body part. sitefinity by default generates attribute.
Here is a link for documentation on how to use custom CSS. Hope this will be helpful:
https://docs.sitefinity.com/custom-themes-and-templates-create-the-css-of-the-theme

Resources