dream-coder.de Blog über .NET, SQL Server, PHP, Typo3 und sonstige Themen

17Jul/080

Controls innerhalb von LoginView ansprechen

Hallo,

manchmal sieht man den Wald vor lauter Bäumen nicht Icon Wink in  // dream-coder.de . Nun suchte ich eine Methode, um auf die Controls innerhalb eines asp:LoginView Controls zuzugreifen.

Fündig geworden bin ich hier, und ich nutze die FindControl Methode so oft ..., manchmal ärgerlich.

Ich zeige es einmal anhand des Beispiels von Thomas.

asp.net
[html]





[/html]

c#
[csharp]

protected void Page_Load(object sender, EventArgs e)
{
Label anonymousLabel = (Label)LVBla.FindControl("AnonymousLabel");

if (anonymousLabel != null) {
anonymousLabel.Text = DateTime.Now.ToString();
}
}
[/csharp]

Und das ganze nochmal in VB.NET

vb.net
[vb]
Dim anonymousLabel As Label = CType(Me.LoginView1.FindControl("AnonymousLabel"), Label)

If Not (anonymousLabel Is Nothing) Then
anonymousLabel.Text = DateTime.Now.ToString()
End If
[/vb]