Jump to content

why there is need of explicit type casting while getting value from sender of linkbutton


rhishi20

Recommended Posts

case1
--------
Protected Sub lnkResdept_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim resdept As String
resdept = sender.text
End Sub
case2
--------
Protected Sub lnkResdept_Click(ByVal sender As Object, ByVal e As System.EventArgs)
resdept= CType(sender, LinkButton).Text
end sub
I am not able to understand difference between these two cases, case1 produces the linkbutton's value for example C1500017 and case2 also produces same result. I am not able to understand why explicit type casting is done in case2.
thanks,
Rhishikesh
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...