如何找到中继器的菜单项ID [英] how to find repeater's menu items id
问题描述
在我的asp.net页面上,我使用中继器显示数据库中的菜单项.当我单击菜单项(链接)时,我想要存储在数据库中的此特定项(链接)的ID.我该怎么做.
主页关于我们服务
o链接1
o link2
o link3
in my asp.net page i use repeater to show menu items from database . when i click a menu item(link) i want id of this particuler item(link) which is stored in database. how can i do this.
Home About us Services
o Link 1
o link2
o link3
推荐答案
只需添加onclick属性,例如
onclick =''getID(this)'';
在javascript中编写函数
Hi,
just add onclick attribute like
onclick=''getID(this)'';
write function inside javascript
function getID(_this)
{
var hide = document.getElementById('hiddenField');
hide.value = _this.id;
}
单击重复项时,您必须在表单中定义隐藏字段,它将自动将id设置为隐藏字段,您将从中获取隐藏字段.
如有任何疑问,请让我知道.
如果有帮助,请提供"投票",如果这是正确的答案,请提供"接受答案".:rose:
谢谢,
Imdadhusen
you should have to define hidden field in your form when you clicked on repeater item it will automatically set id to hidden field and you will get from it.
Please do let me know, if you have any doubt.
Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:
Thanks,
Imdadhusen
这篇关于如何找到中继器的菜单项ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!