Loginview control: how to reference server controls inside a loggedintemplate

In the PageLoad event of the form, I cannot refer to server-side control within the input template. What am I missing. Therefore, when I log in, I will show the control text box, otherwise I will show the text as "please log in to do soso .."

Please, help..

+5
source share
2 answers

you can use the FindControl method for 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 .

+7

- , . , , "DropDownList1", loggedInView. , FindControl DropDownList, NEW-:

DropDownList d = (DropDownList)ucLogin.FindControl("DropDownList1");

       bool answer = d.SelectedValue.StartsWith("S");
       if (answer == true)
       {
           Response.Redirect("~/MemberPages/ChangePassword.aspx");
       }

, "S".

, , !

  • -
-1

All Articles