17Jul/080
Controls innerhalb von LoginView ansprechen
Hallo,
manchmal sieht man den Wald vor lauter Bäumen nicht
. 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
<asp:LoginView id="LVBla" runat="server"> <AnonymousTemplate> <asp:Label ID="AnonymousLabel" runat="server" /> </AnonymousTemplate> </asp:LoginView>
c#
protected void Page_Load(object sender, EventArgs e) { Label anonymousLabel = (Label)LVBla.FindControl("AnonymousLabel"); if (anonymousLabel != null) { anonymousLabel.Text = DateTime.Now.ToString(); } }
Und das ganze nochmal in VB.NET
vb.net
Dim anonymousLabel As Label = CType(Me.LoginView1.FindControl("AnonymousLabel"), Label) If Not (anonymousLabel Is Nothing) Then anonymousLabel.Text = DateTime.Now.ToString() End If

















