2014-09-24 38 views
0

我試圖在DotNetNuke(6.x)中開發一種接觸表單模塊,我想在其中使用RequiredFieldValidator標記來驗證表單。手動刷新後未引用ScriptResource.axd

因爲我也用PLUpload啓用文件上傳,我在我提交按鈕的OnClientClick事件調用javascript函數:

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 
} 

我DNN模塊包含以下這幾個結構輸入字段:

<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> 

,並在表格最後,我有一個提交按鈕:

<asp:Button ID="cmdSubmit" runat="server" 
      Text="Submit" 
      OnClientClick="return startUploadForm(this);" /> 

現在我的問題是,我需要在startUploadForm()函數中調用的客戶端驗證一直不可用。有時,Web服務器不會引用ScriptResource.axd,因此Page_ClientValidate()不可用。我已經通過使用F12查看呈現的頁面源來檢查這一點。

如果我通過直接輸入URL加載頁面,它主要工作,但如果我點擊瀏覽器的刷新按鈕,幾乎每次都會出現問題。

這裏是我試過到目前爲止:

分配ValidationGroups到RequiredFieldValidator的對象和提交按鈕 每個RequiredFieldValidator的對象上定義的屬性enableclientscript =「真」

我做得大幅錯誤這裏?

更新:請參閱我的評論。禁用此特定模塊的DNN緩存後,它工作正常。

+0

我偶然發現了DNN的模塊緩存設置,並注意到我將它設置爲「undefined」,其值爲「0」。現在我已將其更改爲「文件」,同樣值爲「0」,並且初始測試運行時沒有任何問題。這可能是原因嗎? – oxident 2014-09-24 10:57:35

回答

1

我偶然發現了DNN的模塊緩存設置,並注意到我將它設置爲「undefined」,其值爲「0」。現在我已將其更改爲「文件」,同樣值爲「0」,並且初始測試運行時沒有任何問題。