I'm developing a custom module in DotNetNuke 9.9 using Chris Hammond's Module Templates (they're great btw). So far, everything is going well, but I've hit a brick wall with a specific customer requirement: They want to be able to dynamically add additional controls to the form - multiple file upload controls. An example of what I want to achieve can bee seen here: https://www.aspsnippets.c...and-VBNet-in-ASPNet/
For each file that is to be uploaded, they want a textbox to enter the description of the file. The form itself has several other input fields with RequireFieldValidators on them.
I have created a server-side asp:table and my idea was to simply add a new TableRow when the user clicks on the Add File button on the page. The TableRow would consist of 3 TableCells - one with the FileUpload control, one with a textbox for the description, and 1 with a button to allow them to Remove the row if they require. The module has been defined to support Partial Rendering.
This is what the section of the ascx looks like:
<div class="dnnFormItem"> <dnn:label id="lblAttachments" runat="server" /> <div class="editItem"> <asp:Table ID="tblAttachments" runat="server" > <asp:TableHeaderRow ID="thrAttachments" runat="server" > <asp:TableHeaderCell ID="hdrFileName" runat="server" Width="35%" HorizontalAlign="Left" Text="File Name" /> <asp:TableHeaderCell ID="hdrDescription" runat="server" Width="35%" HorizontalAlign="Left" Text="Description" /> <asp:TableHeaderCell ID="hdrRemove" runat="server" Width="5%" HorizontalAlign="Right" /> </asp:TableHeaderRow> </asp:Table> </div>
<div> <asp:linkButton ID="lnkAddFile" resourcekey="lnkAddFile" OnClick="lnkAddFile_Click" runat="server" Cssclass="dnnSecondaryAction" /> </div> </div>
The problem I have is that when I click the Add File button, the validators all fire and display error messages for missing data etc. and the server-side code used to add the row to the table is not actually called.
How can I call the server-side function to add a new row each time the button is clicked without the for actually posting back to the server and triggering the validators? This should only happen when the entire form is actually submitted with the Submit button
What am I missing here? How do I get this button to call the backend via ajax and have the backend manipulate the table?
Thanx, Alon
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.