This project is read-only.

Avoiding unwanted postbacks

Developer
Jan 17, 2011 at 10:09 AM

Anton, 

is there a way to load data server-side from an mdo:service avoiding postbacks?

In some cases I ask data to an mdo:Service, and don't load them via javascript but with mdo:node-set:

 

<xsl:variable name="url" select="mdo:service-url('GetSlides'))">
<xsl:variable name="src" select="mdo:node-set($url)"></xsl:variable>

 

This way I thought I could populate my module in a normal page load, but get strange result when page contains normal dnn modules: looks like there's a postback on page. For example if you look at http://albe.ihnet.it/Software/ODS_Form, you see the sample ODS Form shows validation errors, like the user pressed the submit button (happens with other modules too).

Should I avoid loading data from services this way, include the service template (now that it's possible with include-local)  or is there some other way?

Developer
Jan 17, 2011 at 10:55 AM

Uhm.... looks like the problem is not with node-set: if I just add an empty XsltDb module to a page where some module like ODS is, it immediately comes to postback.

I get the same problem with Dynamic Registration (http://www.datasprings.com/products/dnn-modules/dynamic-registration).

 

Coordinator
Jan 17, 2011 at 1:02 PM

Alberto,

1. It is not good idea to call mdo:service server side... But it is possible. You just have to build complete url as follows:

<xsl:variable name="host" select="concat(
   mdo:aspnet('Request.Url.Scheme'),
   '://',
   mdo:aspnet('Request.Url.Host'),
   ':',
   mdo:aspnet('Request.Url.Port'))"/>

<xsl:variable name="xml" select="mdo:node-set(concat($host, mdo:service-url('test')))"/>

{h{mdo:html($xml)}}

<mdo:service name="test" type="text/xml">
  <root>test</root>
</mdo:service>

2. I've never seen that adding a module lead to page submission... Or I misunderstood you? Can you provide a page with the error?

I've tried installing ODS - it throws an error (wrong placement of square braces)

SQL Execution resulted in following Exceptions: System.Data.SqlClient.SqlException: Incorrect syntax near 'ODSFormItemList'. Must declare the scalar variable "@ModuleID". at ... ALTER PROCEDURE dbo.dnn_[ODSFormItemList] @portalID int, @moduleID int AS SELECT [FormItemID], [ModuleID], [PortalID], [FormType], [FormValue], [FormSelectedValue], [FormLabel], [SortValue], [Optional], [Width], [Height] FROM ODSFormItem WHERE ModuleID=@ModuleID AND PortalID=@PortalID ORDER BY SortValue DESC 

Developer
Jan 17, 2011 at 1:58 PM

Anton,

1. I actually do the same but with a different approach (I have my own mdo:HTTPAlias() function that gives me the equivalent of your "host" variable).

2. Yes and no: this morning I removed my xsltdb module from the page where it was giving me the problem with Dynamic Registration (registration form at http://www.albaris.it/ALBARIS/Profilo_Utente).

The problem is apparently the same with ODS form (see http://albe.ihnet.it/Software/ODS_Form: demo form at middle of page shows validation message when you open the page, like I clicked "submit"). I setup a small test here: http://albe.ihnet.it/Software/Test/ODS

If you wish to do more tests, just register and I'll give you privileges on my site.

 

ODS Form needs to be rewritten actually, at least in the way it handles postbacks (it even validates form when you use the control panel!), but what I don't understand is what is causing the issue, for example in the test page above.

I just uploaded a new version (1.0.4)  which should solve the problem with SQL scripts, if you wish to try.

 

 

 

Developer
Jan 17, 2011 at 2:46 PM

Anton,

I partially solved fake validation on ODS: disabling client-side validation (setting val.EnableClientScript = False for all validators) allows me to correctly use the control panel, no more client-side submit conflicts. However, if I add an empty XsltDb module to the page (not even editing its xslt) it immediately causes form to be validated - see http://albe.ihnet.it/Software/Test/ODS, with client-side validation disabled (note the published 1.0.4 does not contain this fix,yet).

The problem with ODS Form is minor of course, that module needs to be improved, but the kind of error is the same I get with Dynamic Registration for example. 

I still haven't understood what's happening with that empty module... if it's empty it should do nothing, shouldn't it?

 

Coordinator
Jan 17, 2011 at 2:51 PM

Thanks a lot!

Now I see the issue and I'll fix it ASAP. XsltDb calls Page.Validate() regardles current status (postback or not) and validates complete page instead module itself.

You can fix it yourself by removing the following line of code

                    Page.Validate();

from ViewXsltDb.ascx.cs file

Developer
Jan 17, 2011 at 3:15 PM

Ahh!! :-) 

Commenting this out let it all work properly, very good :-) But what is this there for? I'm not aware of any validation function, are there?

Coordinator
Jan 17, 2011 at 3:40 PM

As far as XsltDb allows using ASP.NET controls it must allow validation. Here is a sample of three captchas (http://xsltdb.com/DotNetNuke-telerik-radcaptcha-recaptcha-captchacontrol.aspx), where validation is required. It seems I've forgot to add conditions when validation must occur. Now I see that Page.Validate() must be called manually from within XsltDb configuration. I'll fix it next release.

Developer
Jan 17, 2011 at 4:35 PM

Very very good, thank you. When you have time, in next life, we'd need more documentation about forms :-))

 

Coordinator
Jan 18, 2011 at 7:11 AM

Forms is something that XsltDb missing still...

At the moment I'm finishing researches with ExtJS library. Have you ever deal with it?

But ExtJS is say "developer approach" when you are able to build flexible and complex forms.

I also need something like "admin approach" that allows simple setup, DotNetNuke integration etc. Just like mdo:setup. But I don't want my own solution here. I'd better integrate XsltDb with other modules, that provide forms creation. I'm working now on XML interface to database that will allow save data from POST to database table in one line of code.

After that you maybe will want to integrate ODS with XsltDb. XsltDb may serve as excelent datasource while ODS has good setup capabilities. What do you think about it?

Developer
Jan 18, 2011 at 9:31 AM

Anton,

I never used ExtJS, just read something and found it very very insteresting. I'm currently focusing on jQuery (love it, and more and more integrated into DNN), but want to look deeper at it asap.

Regarding forms, I recently played a little with jQuery Taconite, a very nice plugin that is perfect to work with xml mdo:services: an ajax call to an mdo:service and you're done, very easy and fast. I would also like to make some tests with it and jQuery Forms plugin (both from malsup, great plugins you probably know: http://malsup.com/jquery/). I believe doing forms with XsltDb and these two plugins could be a nice solution, easy to implement, responsive, powerful (XsltDb behind the scenes allow you to do anything) and flexible. I was actually thinking to convert ODS Form to an XsltDb module with this approach :-)

I even did some tests with jquery form, but the problem with ASP.Net forms is that we only have one form per page, and without hacking it a call to post form will include viewstate and all asp.net fields. There are methods to flter forms fields (to include only fields you want) and to automatically serialize form fields within jquery forms, but I could not get these to work yet.

We could also think about XForms (http://www.w3.org/MarkUp/Forms/)... a lot of time ago I read something about this, and now see there are implementations (http://www.w3.org/MarkUp/Forms/wiki/XForms_Implementations) that maybe could come useful, like http://www.agencexml.com/xsltforms , http://ajaxforms.sourceforge.net/ or http://sourceforge.net/projects/formfaces/

 

If I can tell, at present day I would better go with jQuery anyway: there are tons of plugins out there that come useful when you have to build forms (here some samples, old link but just to get an idea: http://www.reynoldsftw.com/2009/01/top-10-jquery-plugins-for-form-usability/).

What do you think about it? ;-)