Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello all,

I want to set in parameter of my Onclick function the value of the ID of each data recovered in my model


when a try that i have an error like :
Invalid or unexpected token


What I have tried:

HTML
<pre>@model List<sotels.smartretail.common.Tenant.SaleDetailVM>

<div class="row">
    <div class="col-md-4">
        <form class="kt-form kt-form--label-right" id="zone_form">
            @Html.AntiForgeryToken()
            <div class="modal fade show" id="m_modal_1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" style="display: block;">
                <div class="modal-dialog modal-dialog-centered modal-xl " role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel"> Details Vente </h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            </button>
                        </div>
                        <div class="modal-body">
                            <div class="alert alert-success" role="alert" id="success" style="display: none">
                                <div class="alert-text">L'enregistrement effectué avec success !</div>
                            </div>
                            <div class="alert alert-danger" role="alert" id="danger" style="display: none">
                                <div class="alert-text">un problème est survenue !</div>
                            </div>
                            <div class="modal-body">
                                <div class="kt-portlet__body">
                                   

                                  
                                </div>


                                <div class="kt-separator kt-separator--border-dashed kt-separator--space-md"></div>
                                <table class="table table-striped- table-bordered table-hover table-checkable" id="sale_table">

                                    <thead>

                                        <tr>
                                            <th> ID Vente </th>
                                            <th> ID Produit </th>
                                            <th> Quantité</th>
                                            <th> En Cadeau </th>
                                            <th> Raison </th>
                                        </tr>
                                    </thead>

                                    @foreach (var items in Model)
                                    {

                                <tr>
                                    <td>
                                        @Html.DisplayFor(model => items.SaleId)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => items.ProductId)
                                    </td>
                                    <td>
                                        @Html.DisplayFor(model => items.Quantity)
                                    </td>

                                    <td>
                                        @Html.DisplayFor(model => items.IsGift)
                                    </td>

                                    <td>
                                        @Html.DisplayFor(model => items.GiftReason)
                                    </td>
                                    <td>
                                        <div class="dropdown dropdown-inline">
                                            <button type="button" class="btn btn-hover-brand btn-elevate-hover btn-icon btn-sm btn-icon-md btn-circle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                 Remises </a>
                                                <div class="dropdown-divider"></div>
                                                <a class="dropdown-item" href="#"  onclick="">^__i class="flaticon-interface-9"> taxes</a>
                                            </div>
                                        </div>
                                    </td>

                                </tr>


                                    }

                                </table>


                            </div>
                        </div>
                        <div class="modal-footer">
                            <div class="form-group">
                                <button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
Posted
Updated 11-Jun-20 9:54am

1 solution

If you want the value of SaleDetailId then

onclick="onDiscountClick(@items.SaleDetailId)"


if you need to pass it as text

onclick="onDiscountClick('@items.SaleDetailId')"


If it is the ID attribue of SaleDetailId you want to pass and not the value of it then use IdFor

onclick="onDiscountClick(@(Html.IdFor(model => model.SaleDetailId)))"


If you want something else you'll need to explain what you want a little better.
 
Share this answer
 
v2
Comments
Member 13220552 12-Jun-20 3:50am    
thanks you dear!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900