-1
    @foreach (var item in outcode)
                   {
             var outc = item;
             if (!codedata.Contains(outc))
             {
                 codedata.Add(outc);
             }
             else
             {
                 Fun();

             }
    }
//this is my C# code and here else condition call JavaScript function.

 function fun() {
                $("table").append('<tr><th><button class="btn btn-secondary" type="button">@Session["dd"]</button> </th> </tr>');
            }

// this is JavaScript function. and this function call when else condition execute in razor code.

2

1 Answer 1

0

Hope this helps

<script type="text/javascript">

    function fun()

    {

    alert('You clicked '+ name +"!");

    }

    </script>

    <div>

        <table class="table table-bordered table-condensed">

            <tr>

                <th>Name</th>

                <th>Department</th>

                <th>Action</th>

            </tr>

            @foreach (Employee emp in Model)

            {

                <tr>

                    <td>

                        <a onclick="AlertName('@String.Format("{0} {1}", emp.FirstName, emp.LastName)')" href="#">@String.Format("{0} {1}", emp.FirstName, emp.LastName)</a>   

                    </td>

                    <td>



                    </td>


                </tr>

            }

        </table>

    </div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.