A
A
Ark Tarusov2019-08-16 15:17:38
JavaScript
Ark Tarusov, 2019-08-16 15:17:38

Is it possible to dynamically add forms in aspnetcore or is it only possible through js?

Hello!
I am writing on asp net core 2.2 and razor page.
There is a need to generate complex forms. Actually the generator wrote, everything is fine.
However, I need to do\add/remove form array elements.
I did not find a way to do this through sharp without refreshing the page, only through js.
however, with js, I also cannot do this, since all the examples found assume that I generate the forms themselves through js and therefore store all the indexes, as well as the indexes themselves, is much simpler. Usually, each element simply has its own index, without prescribing the element's parents in it.
For the interaction of forms with the model, I need to prescribe the full path to the id in each form element.
Actually there are two problems/questions:
1. How to do it in asp?
2. If this cannot be done through asp, then how to connect it all in js. At least an example)

A piece of one of the shapes
<div class="formArray">
    <span title="PrefabIds">PrefabIds</span>
    <div class="formNumber">
        <span>id</span>
        <input type="number" value="0" class="form-control" id="Forms_Attachments_1__Attachments_4__Attachments_3__Attachments_4__Attachments_0__Value" name="Forms.Attachments[1].Attachments[4].Attachments[3].Attachments[4].Attachments[0].Value">
    </div><br>
    <div class="formNumber">
        <span>id</span>
        <input type="number" value="1" class="form-control" id="Forms_Attachments_1__Attachments_4__Attachments_3__Attachments_4__Attachments_1__Value" name="Forms.Attachments[1].Attachments[4].Attachments[3].Attachments[4].Attachments[1].Value">
    </div><br>
    <div class="formNumber">
        <span>id</span>
        <input type="number" value="2" class="form-control" id="Forms_Attachments_1__Attachments_4__Attachments_3__Attachments_4__Attachments_2__Value" name="Forms.Attachments[1].Attachments[4].Attachments[3].Attachments[4].Attachments[2].Value">
    </div><br>
    <div class="formNumber">
        <span>id</span>
        <input type="number" value="3" class="form-control" id="Forms_Attachments_1__Attachments_4__Attachments_3__Attachments_4__Attachments_3__Value" name="Forms.Attachments[1].Attachments[4].Attachments[3].Attachments[4].Attachments[3].Value">
    </div><br>
    <div class="formNumber">
        <span>id</span>
        <input type="number" value="4" class="form-control" id="Forms_Attachments_1__Attachments_4__Attachments_3__Attachments_4__Attachments_4__Value" name="Forms.Attachments[1].Attachments[4].Attachments[3].Attachments[4].Attachments[4].Value">
    </div><br>
</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question