LoginView控件:如何引用里面显示LoggedInTemplate服务器端控件 [英] Loginview control: how to reference server side controls inside loggedintemplate

查看:295
本文介绍了LoginView控件:如何引用里面显示LoggedInTemplate服务器端控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在窗体的p​​ageLoad的事件,我不能引用服务器端的控制范围内登录模板。我在想什么。所以,当我登录我将显示文本框控件,否则我将显示文本,如请登录搜搜做的。

In PageLoad event of the form, I can not reference server side control within logged in template. What am I missing. So when I am logged in I will show text box control otherwise I will show text like "please login to do soso.."

请帮助..

推荐答案

您可以使用您LoginView控件FindControl方法,让他们...

you can use the FindControl method on your loginview control to get them...

TextBox t = (TextBox)LoginView2.FindControl("TextBox1");
string s = null;

if (t != null)
{
    // textbox is in the current scope of the LoginView
    s = t.text;
}
else
{
    // the textbox is not in the current scope of the LoginView.
}

然而,这将仅对于目前在LoginView控件的所示视图中的控制工作。你必须测试你展示鉴于登录试图抓住文本之前,或者你也可以测试该的FindControl不返回空引用。

However, this will only work for the controls that are currently in the shown view of the LoginView control. You'd have to test that you're showing the logged in view before trying to grab the textbox, or you could also test that the FindControl doesn't return a null reference.

这篇关于LoginView控件:如何引用里面显示LoggedInTemplate服务器端控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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