Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Weird typing in ASP.NET
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
Database:
Visual FoxPro
Divers
Thread ID:
01471265
Message ID:
01471267
Vues:
46
>I sort of understand this casting or typing subject in ASP.NET, and C# specifically, but it's just weird, coming from a Visual FoxPro background. An example of this follows from Stephen Walther's book, titled "ASP.NET 3.5 Unleashed". The value that is found with the FindControl function is already coming from a textbox, and yet the value has to be Typed as a TextBox? Or, maybe it's not quite a TextBox, because the FindControl() function is only finding the txtSearch control on the PreviousPage, not really able to return it as a TextBox object? I suppose this is more C# language "stuff", not really confined to ASP.NET. As a VFP guy, it's a bit weird, although somewhat understandable with repetition and useage.
>
>This code is found on page 99:
>
>TextBox txtSearch = (TextBox)PreviousPage.FindControl("txtSearch");
>lblSearch.Text = String.Format("Search For: {0}", txtSearch.Text);
>
It is a DotNet thing. FindControl() returns a System.Web.UI.Control. To access that control's .Text property you need to cast the control to a TextBox.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform