The answer is in the error message, somewhere you are trying to cast the webform itself (rather than a button element on the form) to type
Button
The offending line is likely to be :
Dim btn As Button = DirectCast(sender, Button)
But it is difficult to tell from your code (we don't know what is calling this function and you don't say where the error occurs). If it is this line,
sender
is the form itself rather than a button. You can check by putting a breakpoint on the line and hovering over sender when it is hit to inspect what it is.
It is impossible to give you an exact fix with the supplied code, but once you have worked out where the error is happening, you should get the button you want to cast from the form object that is currently throwing the error.