Can Validation Be Improved?

Can Validation Be Improved?

Old forum URL: forums.lhotka.net/forums/t/692.aspx


Smeat posted on Friday, July 21, 2006

This may already be possible or it may not be possible at all, so feel free to shoot me down in flames.

In a web forms application, the user does whatever they need to do and then we post back to the server, send the data into the business object and then validate the state of that object.

Is it possible to do this without causing a postback by using AJAX technology?

I.e. When the user clicks save, before posting back to the server, have AJAX talk to the server and do the validation.

I suspect this is not possible but wanted to get your opinions.

Smeat

JHurrell replied on Friday, July 21, 2006

I've used MagicAjax to do this. There is a control called a MagicPanel in which you can place any controls you like. You can set everything to AutoPostback and not worry about a traditional postback.

When controls do postback, MagicAjax intercept and do so asynchronously. Merely bind your controls as your normally would. Your controls will postback to the server, updating your BOs and rules. If you've bound your BrokenRules to a list and IsSavable to a button, you're golden.

- John


skagen00 replied on Friday, July 21, 2006

Here's an idea for you that I thought of after thinking about your question...

I did a quick test with Atlas and I think this might be a nice solution... I'd have to play around with it more to be sure. Here was my test.

Add a textbox, label, and a button to a Web form on an Atlas page.

Wrap the button and label in an update panel. Enable partial rendering on the scriptmanager that you also have to add prior to the update panel. (This button would be your save button).

On the clicked event of the button, label1.Text = textBox1.Text;.

Now, when one clicks the button, it does the asynchronous postback and label1.Text is set to textBox1.text without doing a full postback.

The idea is that by wrapping a Save button in an update panel, you can allow the object to be updated behind the scenes, check it's validity, and optionally save the object too. All without a post-back.

Edit: Kind of just reiterating what the prior poster said I guess, I apologize.

Copyright (c) Marimer LLC