Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

c# - Reusable Form Modal for Razor Pages table list

First of: I cannot use blazor as of now. I have a razor page application that list items from the database. Each of these items have a form that they can edit. I know this can be done if you go to a new page. What I am trying to accomplish is to use one modal for all the forms in the table.

                            <tbody>
                                @for (int i = 0; i < @Model.List.Count; i++)
                                {

                                    <tr>
                                        <td><a>@Model.AddressList[i].Description</a></td>
                                        <td>@Model.List[i].Address1 </td>
                                        <td>@Model.List[i].City</td>
                                        <td>@Model.List[i].StateAbbr</td>
                                        <td>@Model.List[i].Zipcode</td>
                                        <td>@Model.List[i].CountryAbbr</td>
                                        <td>
                                            <button class="btn btn-secondary" data-toggle="modal" 
                                         data-target="#addressModal">Edit</button>
                                        </td>
                                    </tr>

Each tr has its button to call this modal:

<div class="modal fade" id="addressModal" tabindex="-1" role="dialog">...

I know razor and html are rendered separately, but I was hoping there was a way to to do this without having to go to a new page or write a lot of javascript?

question from:https://stackoverflow.com/questions/66051694/reusable-form-modal-for-razor-pages-table-list

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...