'System.Web.UI.ITemplate' does not contain a definition for 'FindControl'
<p>I tried to get the LoginName control inside LoginView LoggedIn template , despite several methods, the code still could not work.</p>

<p>I wished to change the default username to the customer name. I tried finding the control inside the LoggedInTemplate but this error appear :</p>

<pre><code> 'System.Web.UI.ITemplate' does not contain a definition for 'FindControl' and no extension method 'FindControl' accepting a first argument of type 'System.Web.UI.ITemplate' could be found (are you missing a using directive or an assembly reference?
</code></pre>

<p>Here is the code: </p>

<pre><code> &lt;asp:LoginView ID="LoginView1" runat="server"&gt;
   &lt;LoggedInTemplate&gt; 


                 Hello, &lt;asp:LoginName ID="LoginName1" runat="server"&gt;&lt;/asp:LoginName&gt;

                 &lt;br /&gt; 

                 &lt;div style="text-align: right; margin-right: 5px "&gt; 
                &lt;asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="~/Home.aspx" Font-Underline="True" /&gt;
                &lt;/div&gt;&lt;/div&gt;
        &lt;/LoggedInTemplate&gt;


    &lt;/asp:LoginView&gt;  
</code></pre>

<p>code at the back: </p>

<pre><code>protected void Login1_LoggedIn(object sender, EventArgs e)
    {

        LoginName loginName = LoginView1.LoggedInTemplate.FindControl("LoginName1") as LoginName;
       // LoginName loginName = LoginView1.FindControl("LoginName1") as LoginName;

       // loginName.FormatString = fullName;

    }
</code></pre>
