Jump to content

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


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...