c#代码,用于使用其类名获取控件的ID [英] c# code for get ID of the control using its class name

查看:92
本文介绍了c#代码,用于使用其类名获取控件的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,



如何在asp.net C中使用其类名获取控件的ID#



谢谢和问候,

Dileep

Dear Experts,

How to get the ID of a control using its class name in asp.net C#

Thanks and Regards,
Dileep

推荐答案

你不能只根据类名来做。类名和 id 完全不相关。想一想:同一个类可以用于不同的对象,但 id 值在页面上应始终是唯一的。所以,请求根本没有意义;答案很明显。



你可以得到一些更有用的建议,你解释了你想要达到的目标。



-SA
You cannot do it based on just the class name. A class name and id are totally unrelated. Just think about it: the same class can be used for different objects, but id values should always be unique on the page. So, the request simply makes no sense; the answer it obvious.

You could get some more useful advice is you explained what do you want to achieve.

—SA


如果打算用CSS类而不是ID访问控件,那么你可以在C#中以多种方式完成它。



参考



如何到选择-AN-元件逐类代替-的-ID-在-ASP -net [ ^ ]
If the intention was to access the controls with CSS class instead of ID, then you can do it in multiple ways in C#.

Refer

how-to-select-an-element-by-class-instead-of-id-in-asp-net[^]


你可以使用jquery或javascript通过使用类名来获取控件的id
you can use jquery or javascript get the id of controls by using class name


这篇关于c#代码,用于使用其类名获取控件的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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