New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the Community Exchange, where community members ask and answer questions about DNN. To get started, just start typing your question below and either select one of the suggested questions or ask a new question of your own.

How can I have an indeterminate number of dnnFormItem div elements in my Settings.ascx?

Return to previous page

  • 7/20/2017
  • 1346 Views
Tags:

Question:

James Maher 7 years ago

I am trying to have a way for the user to specify the number of inputs for a certain section of the Settings page in my module. I want the user to be able to enter a number (e.g. 5), click "Update", reload the Settings, and see five new text boxes. I have done this in an MVC module like so:

<div class="dnnFormItem">

@Dnn.Label("QueryParamCount", "Count", "Number of URL parameters")

@Html.TextBoxFor(m => Model.QueryParamCount)

</div><br />

if (Model.QueryParamCount > 0)

{

<div>

@Dnn.Label("QueryParamList", "Parameters", "List of URL parameters;" +

"Valid data types are: bigint, bit, smallint, decimal, smallmoney, int, tinyint, money, float, real, date, datetimeoffset, datetime2," +

"smalldatetime, datetime, time, nchar, nvarchar")

<br />

<table id="ParameterTable_@Dnn.ModuleContext.TabModuleId" align="center">

<colgroup>

<col style="width:200px" title="Value" />

<col style="width:150px" title="Data Type" />

</colgroup>

@for (int i = 0; i < Model.QueryParamCount; i++)

{

<tr>

<td>

@Html.TextBoxFor(m => m.QueryParamList[i].Value, new { placeholder = "Name" })

</td>

<td>

@Html.TextBoxFor(m => m.QueryParamList[i].DataType, new { placeholder = "Type" })

</td>

</tr>

}

</table>

</div><br />

}

Because of how the module that I am currently working on does not have the concept of a "Model," I cannot use the same approach. Is what I am trying to do even possible without resorting to MVC?

How can I have an indeterminate number of dnnFormItem div elements in my Settings.ascx?

James Maher
James Maher 7 years ago
Add an Answer

Answers

Sign In to Participate
Or register to become a member