从.cs文件访问用户控件 [英] Accessing User Control from .cs file

查看:74
本文介绍了从.cs文件访问用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,
1)我的问题是我想从文件后面的代码访问并调用用户控件,并在页面的特定列中显示.
2)我想为我站点的不同用户设置相同用户控件的特权.

谢谢
Bilal Hassan

Hey,
1)my problem is that i want to access and calling user control from code behind file and display at particular column of my page.
2) i want to set privileges of same user control for different user of my site.

Thanks
Bilal Hassan

推荐答案

好,

有很多链接可以告诉您如何在运行时添加用户控件,这是一个:
http://www.beansoftware.com/ASP.NET-Tutorials/Controls-Run- Time.aspx [ ^ ]
如果以上链接没有帮助您在Google上查找在运行时asp.net添加用户控件",您将找到成千上万个链接.

对于条件逻辑,您可以简单地输入If ... usertype == Admin类型的代码,并采取措施添加或不添加用户控件.

谢谢,
提示
Well,

there are many links can tell you how to add user control at runtime, here is one:
http://www.beansoftware.com/ASP.NET-Tutorials/Controls-Run-Time.aspx[^]
if the above link doesn''t help you google for "add user control at runtime asp.net" you will find thousands of links.

For condition logic you can simply put If...usertype==Admin kind of code and take action to add or not to add the user control.

Thanks,
Hemant


您的问题不是很清楚,但是一旦添加了适当的名称空间,您就应该能够在代码中使用用户控件.
Your question is not very clear, however you should be able to use a usercontrol in your code once you have added the proper namespaces .


放置一个占位符并动态加载控件.它可以从后面的代码中完成,因此您可以将代码放入条件语句中,并相应地对用户进行身份验证.

另一种解决方案是直接在源代码中使用if-else块,并检查是否允许用户查看控件.

希望你明白我的意思...
Put a place holder and load the control dynamically. It can be done from code behind, so that you can put your code in conditional statement and authenticate user accordingly.

Another solution is to use if-else block directly in the source, and check whether user is permitted to view the control or not.

Hope you got my point...


这篇关于从.cs文件访问用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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