Answered by:
Parameters

Question
-
User-797751191 posted
Hi
How to pass Parameters thru editpop() in the below code
<a class="btn btn-danger btn-xs" onclick="editPop()"><i class="fa fa-ban"></i></a>
function editPop() {
$("#myModal").modal();
}Thanks
Friday, June 28, 2019 8:12 AM
Answers
-
User61956409 posted
Hi jsshivalik,
If you'd like to pass Eval values as parameters to your JavaScript function, as you asked in [another thread](https://forums.asp.net/t/2157190.aspx), please try:
onclick='<%# string.Format("editPop({0}, \"{1}\");", Eval("No"), Eval("Id")) %>'
With Regards,
Fei Han
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 9:30 AM
All replies
-
User-1038772411 posted
Hello Jsshivalik,
Refer the following code,
The below code does that. The JavaScript function AlertName() takes a input parameter name to pass the employee name during the onclick event.
<script type="text/javascript"> function AlertName(name) { 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> @emp.Department.DepartmentName </td> <td>@Html.ActionLink("Edit", "edit", new { id = emp.EmployeeId })</td> </tr> } </table> </div>
For more details refer the following link
http://www.codedigest.com/posts/35/adding-javascript-in-aspnet-mvc-views
Thank you.
Friday, June 28, 2019 8:29 AM -
User-797751191 posted
Hi
I need in Asp.net c#
Thanks
Friday, June 28, 2019 8:31 AM -
User61956409 posted
Hi jsshivalik,
If you'd like to pass Eval values as parameters to your JavaScript function, as you asked in [another thread](https://forums.asp.net/t/2157190.aspx), please try:
onclick='<%# string.Format("editPop({0}, \"{1}\");", Eval("No"), Eval("Id")) %>'
With Regards,
Fei Han
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 9:30 AM