We have looked and looked all over the internet but we were unable to find a solution. We have a linkbutton and we want to pass a parameter to the code behind. This is the code:
<% foreach (Academia.CourseEN curso in MyCourses) { %>
<% string id = curso.Id.ToString(); %>
<div class="col-xs-12 col-sm-5 col-md-5 col-lg-3">
<div class="panel panel-warning">
<div class="panel-heading"><%: curso.Title %></div>
<div class="panel-body"><%: curso.Id %></div>
<div class="panel-body"><%: curso.Description %></div>
<div class="panel-body"><%: curso.Price %></div>
<div class="panel-body"><%: curso.Category %></div>
<div class="panel-body">
<div class="col-md-offset-2 col-md-10">
<asp:LinkButton ID="ENameLinkBtn" runat="server" Text="Button" CommandArgument='<%# Eval("id") %>' OnClick="DeleteCourse_Click" ></asp:LinkButton>
</div>
</div>
</div>
</div>
<%} %>
The problem is that eval always returns an empty value, which is not the case as when we display the id it has a value. I post the code behind code as well:
LinkButton btn = (LinkButton)(sender);
string yourValue = btn.CommandArgument;
ErrorMessage.Text = yourValue;
I dont know what else to do or what else to try, anything would behighly appreciated. Thanks everyone.
You can create a javascript function DeleteCourse()
function DeleteCourse()
{
var param = $("#ENameLinkBtn").val();
$.ajax(
url:"your web method",
data: '"param":"' + param + '"'
....)
}
Then assign it to your button OnClick="DeleteCourse()"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.