Asp.net form validation using Validation configuration file - asp.net

Currently I have a requirement to validate(server side) forms in ASP.net (not MVC). We have several fields in our form which gets data from active directory. Instead of using inbuilt .net validation control, the requirement was to use a configuration setting for all validations, which can be easily edited.I am planning to use XML(or any other similar alternative) as configuration Editor.
Initially I thought (still thinking) this is simple task to achieve. But when I searched for similar implementation, i couldn't find one. Some of the implementation which i saw uses a very complex approach. The whole idea was to keep the validation settings as simple and as dynamic as possible.
I would appreciate if anyone can direct me to a similar implementation or give suggestions with respect to this.

After some research I found this article very useful. It introduced me the validation block in Enterprise Library 5.0 which can be customized as per our requirement.

Related

Alternatives to asp.net ajax 4.0 templates

Assuming I'm stuck with asp.net web forms (I'd love to use MVC partial views), are there any good alternatives to asp.net AJAX 4.0 client-side templates?
In other words, is there some way to specify some html, with placeholders for data properties, to which I could then bind a JSON result. Are there any good jQuery plugins to do this?
I ask because based on the results I'm seeing from Google, this library doesn't seem to be widely used—most search results are from 2008-2010. This question seems to confirm that suspicion.
EDIT
I despise answering my own question, but this link (jQuery Templates) seems to me to be the best bet. If anyone else has any input, please post.
Definitely consider jQuery Templates. We use them quite extensively in WebForms with ScriptServices as a data provider. There is a very small learning curve.
Also check out KnockoutJS, which integrates seamlessly.
Adam, coincidentally, I am using JQuery to retrieve some server side data calling Web Services via Ajax and binding the result on the client side. On my particular case, I am only showing data in a tabular manner, so I am using the jquery datatables plugin (which is fantastic, in my opinion; the API is well documented and easy to extend if you need to).
If you need to show data differently, I think you'll need to write quite a good amount of boilerplate javascript code.
EDIT: I just saw your link reagarding Jquery Templates and looks really cool. I didn't know it existed :) Thanks!

how complex can an ASP.NET web page be?

I'm building a Bridge game.
The main page, where you play the game, boast some 200 controls, like buttons that represents the 52 cards, 26 others for won / lost tricks, plenty of text fields... You name it, total some 200.
Actually its been already built and runs under Winforms model, but with the unavoidable question of implementing .NET 4.0 onto user's machine that must run Windows, and installing the software.
Hence I'm considering creating an ASP version (no PHP please, since I'm fluent in VB, and ignorant in C, Java, PHP and the likes).
Is that a "real" option or am I dreaming?
Will it run smoothly for users with a 2MB DSL connection?
Oh, by the way, no MVC please, I'm too old for that sort of sh...t :->
Can it be done? Sure.
The problem for you might be that to do it effectivly you will need to use HTML, CSS, Javascript and the like.
What most likely would be a good idea for you here would be to go the route of Silverlight. It will give you a more rich UI experience and will allow you to code in VB entirely.
I don't see using ASP.BET directly as a good option here. To make it look smooth, you would have to use javascript heavily. I thing you would be better off with Flash.
If you prefer to use pure HTML/Javascript/CSS you can create rich Web UI's by modifying the Document's Object Model (DOM). With little knowledge of Javascript and the usage of some library like: scriptaculus, prototype, sarissa, jquery, you can get rich interfaces. You should take a look at some of these libraries mainly scriptaculus because the set of animations it provides. Another javascript library made for game development is gameQuery.
With that many controls on an ASP.NET page your view state will be gigantic. If you plan on only serving up a couple of games at once then it shouldn't be a problem but you have to actually start thinking about bandwidth with that large of a viewstate. You would be better off with a DOM/jQuery type interface which displayed static images for the cards. All interaction can be handled client side and validated with a server side call.
This might be the perfect opportunity to learn javascript :). Remember each language you learn is another tool in your toolbox. The engineer with the most tools usually wins :).

Best way to do client/server validation in ASP.NET in 2010?

First there was the ASP.NET validators and we used them... Then some people on the team did things manually in javascript... Then a bunch of jquery validation libraries came out... Then MVC2 came out with attributes as validators..
I work with apps that have alot of forms with alot of various validation (Some fields needs to be compared with other values in a DB so a postball/ajax call is required) .. Right now I have a mess of ASP.NET custom validators and functions that calculate on the server side as well.
Can I get some opinions on the best tool/combination to approach this job that can create the smallest/most elegant code? Pure server side solution? AJAX/Jquery? A certain plugin for jquery?
For example, I have 2 dates.. I want to make sure that the 1st date is less than the 2nd date... Are there jquery validators that encapsulate this? My feeling is if I can get jquery plugins to handle half the more basic validation for my that could cut my code in half.
DynamicData for asp.net mvc and dynamic data.
On webforms I have only used the the asp.net validators approach. This doesn't mean to go copy-pasting all over custom validations you may have i.e. you add your own custom validators as needed and only on very special circumstances you use extra validators hooked to methods+scripts on the page.
Depending on how you structure your code, I would expect to be able to leverage some of the infrastructure around DataAnnotations. I can't give it for a fact, you know the usual issues on asp.net something usually tied up to implementation details, worth a shot if there aren't better options.
Update 1:
a v. quick search gave: http://blogs.microsoft.co.il/blogs/gilf/archive/2010/04/08/building-asp-net-validator-using-data-annotations.aspx, which is rudimentary piece - but shows a way that you can leverage the data annotations on web forms (for the server side).
Update 2: another one with the same approach as above, but does both server & client side validation:
http://geeks.ms/blogs/rcarreras/archive/2010/04/20/validando-asp-net-web-form-con-dataannotation-en-ambos-lado-cliente-y-servidor.aspx. Again rudimentary, but certainly can be used as the basis to get a more complete automatic validation based on the annotations. Note: depending on what you use you can have the validators automatically added on the appropriate places, although I must warn that it might be tricky to get it to work well if you haven't worked with dynamically added validators before
If you're using ASP.NET MVC, I recommend the DataAnnotations attributes across the board. There are "simple" ones included for required fields and length, and you can write your own custom validators for comparison of two fields and others. Phil Haack as a great article all about custom validators in ASP.NET MVC.
I usually use jquery RSV plugin http://plugins.jquery.com/project/RSV to do my validation job for the normal stuff, and i code my own jquery functions for the more complicated validation (requiring ajax calls and stuff)
and i always re-validate on the server side.

using SqlSettingsProvider with asp.net

We want to move our asp.net settings from web.config to a database. All of the examples I see for SqlSettingsProvider are Winform apps.
Can SqlSettingsProvider be used with asp.net?
If not, can someone suggest an alternative?
Thanks
According to MSDN the SqlSettingProvider attribute can only be used for classes derived from ApplicationSettingsBase. As this class is Windows Forms specific and this is stated explicitly in the documentation it means you cannot use this functionality in a web context. (See http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx for details).
To work around this and get similar functionality I would advise you to create a custom SettingsProviderBase class and implement the setting storage strategy that you need. Using this approach will also allow you to unit test the classes that are depending on application settings.

Best way to learn Ext JS for use with ASP.NET?

I have very basic knowledge of Javascript and now I am looking forward to learn Ext JS and implement in in my ASP.NET application.
If anyone can guide me on how to start and which book I should follow, I'd be thankful.
Nor sure if it is the quickest approach, but all I did (as well as another developer that was working with me) was review the ExtJS documentation and samples gallery (and viewing their source).
One big issue to watch out for when using ExtJS with ASP.NET is that when using BorderLayout you will go crazy trying to figure out why Postbacks no longer work. There is a workaround though.
Another ASP.NET gotcha is that if you use ExtJS to talk with ASP.NET web services (or WCF) you have to do some special things to get it to work (adorn your webmethod with special attributes, or add some things to web.config, etc).
Those were the only two gotchas I can recall, other than just learning and getting the hang of ExtJS itself.

Resources