通过C#引用自定义控件 [英] Referencing custom controls via C#

查看:182
本文介绍了通过C#引用自定义控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

有什么简单的方法可以解决波纹管情况?
我有一个自定义的用户控件.该控件内部包含多个TextBox控件.
在页面中,我生成了这些控件,因此我可能拥有1到30个这些自定义用户控件.这些控件是从C#代码(文件后面的代码)生成的.

当用户按下按钮时,我需要分别获取这些控件,以便可以从这些文本框中获取值.我通过属性公开了这些文本框值,所以这里唯一的问题是如何到达父级(单个自定义控件).

谢谢!

Hello,

Any simple solution to bellow situation?

I have a custom user control. That controls contains several TextBox controls inside.
In page I generate these controls so I might have between 1 and 30 of these custom user controls. These controls are generated from C# code (code behind file).

When user presses a button I need to get these controls individually so I could get the values from these textboxes. I am exposing these textbox values though properties, so the only problem here is how to get to the parent (individual custom control).

Thanks!

推荐答案

尝试使用
Try using FindControl[^] - the link includes an example.


这里是一个如何在ASP.NET中找到子控件的想法:http://stackoverflow.com/questions/11416959/c-sharp-error-using-findcontrol-on- div-id [ ^ ]

我建议创建用户控件.有关更多信息,请参见:
ASP .NET中的用户控件 [ ASP.NET用户控件 [
Here is an idea how to find child control in ASP.NET: http://stackoverflow.com/questions/11416959/c-sharp-error-using-findcontrol-on-div-id[^]

I''d suggest to create user control. For further information, please see:
User controls in ASP .NET[^]
ASP.NET User Controls[^]


这篇关于通过C#引用自定义控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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