I'm trying to develop a kind of contact form module in DotNetNuke (6.x) in which I want to use the RequiredFieldValidator tag in order to validate the form.
Because I also use PLUpload to enable file uploads, I'm calling a javascript function in the OnClientClick event of my submit button:
function startUploadForm(objBtn)
{
if (Page_ClientValidate()) {
var uploader = $('#uploader').pluploadQueue();
if (uploader.files.length == 0) return true; // Input is complete -> No running uploads -> Validation ok -> submit
uploader.bind('UploadComplete', function () {
__doPostBack('<%= cmdSubmit.UniqueID%>', ''); // Input is complete -> uploads finished -> Validation ok -> submit
});
if (uploader.files.length == (uploader.total.uploaded + uploader.total.failed)) return true; // Input is complete -> uploads finished -> Validation ok -> submit
uploader.start();
return false; // asynchronous upload isn't finished -> don't submit
}
return false; // Input isn't complete -> Validation failed -> don't submit
}
My DNN module contains several input fields following this structure:
<asp:TextBox ID="SenderName" runat="server" Columns="40" Width="300px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqName" runat="server"
ControlToValidate="SenderName"
ErrorMessage="(required)"
SetFocusOnError="True">
</asp:RequiredFieldValidator>
And at the end of the form, I've got a submit button:
<asp:Button ID="cmdSubmit" runat="server"
Text="Submit"
OnClientClick="return startUploadForm(this);" />
Now my problem is that the client side validation I need to call in the startUploadForm() function isn't available all of the time. Sometimes, the webserver won't reference ScriptResource.axd and therefore, Page_ClientValidate() isn't available. I've checked this by looking at the rendered page source using F12.
If I load the page by directly entering the URL, it mostly works but if I hit the browser's refresh button, the problem occurs almost every time.
Here's what I've tried so far:
Assigning ValidationGroups to the RequiredFieldValidator objects and the submit button Defining the property enableclientscript="true" on each RequiredFieldValidator object
Am I doing something substantially wrong here?
UPDATE: Please see my comment. After disabling DNN cache for this particular module, it works fine.
I stumbled upon DNN's module cache setting and noticed that I had it set to "undefined" with a value of "0". Now I've changed it to "File", again with a value of "0" and initial tests ran without any problems.