After months of grinding the knowledge and concievable possibilities (which aint too much on my part :) ), I have developed a series of methods, that i am using on a project atm, that allows me to access a property for a WebControl, Control, or specific property for a control through Generics Hierarchy.
Below i will list the core and the supports then the specifics. Regardless of what type it is, they all use the ControlRef core method to get a control instance before access its specific properties or methods.
You can find the snippet at FindControl
Some example uses of a higher level generic:
An even higher level generic:
Edited (2/26/2010):
Found out that this Snippet i posted above had been deleted, with no response, so here it is in its form and usage.
snippet address was: Here
Below i will list the core and the supports then the specifics. Regardless of what type it is, they all use the ControlRef core method to get a control instance before access its specific properties or methods.
You can find the snippet at FindControl
Friend Function ControlRef(Of T As Control)(ByVal parent As Control, ByVal cntrlName As String) As T Return CType(parent.FindControl(cntrlName), T) End Function
Some example uses of a higher level generic:
Friend Function GetVisible(Of T As Control)(ByVal parent As Control, ByVal cntrlName As String) As Boolean Return ControlRef(Of T)(parent, cntrlName).Visible End Function Friend Sub SetVisible(Of T As Control)(ByVal parent As Control, ByVal cntrlName As String, ByVal value As Boolean) ControlRef(Of T)(parent, cntrlName).Visible = value End Sub
An even higher level generic:
Friend Function GetSelected(Of T As DropDownList)(ByVal parent As Control, ByVal cntrlname As String) As ListItem Return ControlRef(Of T)(parent, cntrlname).SelectedItem End Function
Edited (2/26/2010):
Found out that this Snippet i posted above had been deleted, with no response, so here it is in its form and usage.
snippet address was: Here
0 Comments On This Entry
Trackbacks for this entry [ Trackback URL ]
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
My Blog Links
Search My Blog
Recent Entries
-
FindControl generic methodson Feb 25 2010 01:35 PM
-
-
-
-
|
|



Leave Comment










|