将项添加到Web用户控件 [英] Adding items to a web user control

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

问题描述

大家好。我已经能够在我的页面中获得用户conrtol。但是,我从未在web使用conrtol中添加项目。原始控件有学生和教师的链接.Currenrlly,我需要更改这些链接当学生登录时。当学生登录时,他可以看到一些管理页面,但现在我需要在登录时向他显示不同的链接。有人可以指导我如何在页面中添加项目吗?这是我的控件代码

 LoginView控件=(LoginView)Master.FindControl(  LoginView1\" ); 
var cont =(StudentsPanel)control.FindControl( StudentsPanel);
if (cont!= null
{

// 这是我需要添加这些链接的地方,例如,因为他以学生身份登录,我会隐藏使用管理页面的原始控件,然后添加到Cont
控件的新链接。
}





我怎样才能完成这个?

解决方案

你可以试试像



 LoginView control =(LoginView)Master.FindControl(   LoginView1); 
var cont =(StudentsPanel)control.FindControl( StudentsPanel);
if (cont!= null
{
controlID。控件。添加(在此处将您的控件' s id写入添加控制);

}





同样可以使用controls.remove方法删除控件。


Hi all.I have been able to get the user conrtol in my page.However,i have never added items to a web use conrtol.The original control has links to STUDENTS and Teachers.Currenrltly,i need to change those links when a student logs in.At the moment,when a student logs in,he can be able to see some admin pages but now i need to show him different links on logging.Can someone guide me how to add the items in a page?Here is my code of the control

LoginView control = (LoginView)Master.FindControl("LoginView1");
           var cont= (StudentsPanel)control.FindControl("StudentsPanel");
           if (cont!= null)
           {

            //Here  is where i need to add those links eg.since he his logged in a s a student,i will hide the original control with the admin pages and then add new links to the "Cont"
control.
           }



How can i accomplish thi?

解决方案

you can try something like

LoginView control = (LoginView)Master.FindControl("LoginView1");
           var cont= (StudentsPanel)control.FindControl("StudentsPanel");
           if (cont!= null)
           {
 controlID.controls.add(Write your control's id here to add control); 
          
           }



same way you can use controls.remove method to remove the controls.


这篇关于将项添加到Web用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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