Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Weird typing in ASP.NET
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01471265
Message ID:
01471271
Views:
48
I guess this is just the way it is, not like Visual FoxPro which is a bit more straightforward. So, the bottom line is that you must type it as a TextBox in order to get to the Text property.

Thanks,
Cecil

>>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform