Sign in to follow this  
Followers 0
rhishi20

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

3 posts in this topic

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

Share this post


Link to post
Share on other sites

It's just 2 ways to do the same thing. You can either access the text property, or you can convert the sender object to a Text type (which probably accesses the text property behind the scenes).

1 person likes this

Share this post


Link to post
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
Sign in to follow this  
Followers 0