Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unreachable control
Message
De
02/06/2006 14:48:40
 
 
À
02/06/2006 11:38:59
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01126708
Message ID:
01126802
Vues:
16
I've used it only when necessary. For example if you subclass any of the web controls and you want certain behavior to be built in. Or if you add controls dynamically. Otherwise you could select the control and then select the desired handler from the events dropdown. No need to reinvent the wheel if VS can do it for you..

UPDATE: sorry forgot to mention where you would place the call..

You would want your behavior to be present before the user can interact with the control, so any event that fires between initialization and rendering of the page should work.. Prerender on the page, for example.

>The GridView in 2005 is might handy. Jump in the water is fine.
>
>I am still a little hazy on how and when to use the AddHandler statement. Do I get an object reference and create the handler with the AddHandler in the Load event (if not ispostback)?
>
>Thanks
>
>Glenn
>
>>>I have a WebForm which has upon it a GridView. Defined in the GridView header template is an Asp control. I need to reference that control in the Code-Behind but there seems to be no way to get to it. Is there any way to access this object besides Me.GridView1.HeaderRow.FindControl("BtnSortBy")? And if so how do I construct an event handler for it?
>>>
>>>Thanks
>>>
>>>Glenn
>>
>>I have not jumped in the VS 2005 "bandwagon" yet but this is how you can do it in VS 2003:
>>
>>1) For finding a control without using FindControl you can loop through the Controls collection of the container object. Not pretty, but you can do it..
>>
For Each ctl In Me.GridView1.HeaderRow
>>  If ctl.HasControls Then ..
>>    '.. etc.
>>.. then compare the ID of the controls to the one you are trying to find. (I said it wasn't pretty)
>>
>>2) To associate an event handler you can use AddHandler:
>>
AddHandler myBtn.PreRender, AddressOf myBtn_PreRender
>>Where myBtn_PreRender is a Sub that you provide, preferably with the same signature as you would get if VS creates the handler for you. (as when you dbl-click on the aspx surface to get your Page_Load)
>>
>>I hear the GridView is soo much better than the regular DataGrid in 2003, I sure hope so. I had to jump through hoops to customize this control on a recent project.. HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform