在代码隐藏中获取按钮值 [英] getting button value in codebehind

查看:82
本文介绍了在代码隐藏中获取按钮值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图像这样获得job_id.现在我将如何在代码中获得价值.我正在使用数据列表..

I am trying as like this to get job_id.Now how i will get value in code behind. I am using datalist..

<asp:ImageButton name='<%#Eval("Job_ID") %>' ID="btnApply" runat="server" ImageUrl="Images/submit_btn_18.png" onclick="btnApply_Click" />

推荐答案

这应该有效:

This should work:

protected void btnApply_Click(object sender, EventArgs e)
{
   //assuming jobid is an integer
   int jobid = int.Parse(((ImageButton)sender).Attributes["name"]);
}



这有助于您访问在控件上定义的自定义属性.



This helps you access the custom attributes you define on a control.


这篇关于在代码隐藏中获取按钮值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆