Link to home
Start Free TrialLog in
Avatar of martie_11
martie_11Flag for United States of America

asked on

Convert to VB.NET

Not sure if this should be in the C# area or here, but nonetheless here's what I'd like to convert to VB.NET:

public void btnCloseTask_Click(object sender, System.EventArgs e)
{
     Button myButton = sender as Button;
     Response.Write("<script>alert(" + myButton.CommandArgument + ")</script>");
     //Redirect code goes here
}

Here's how far I've gotten:

Public Sub btnCloseTask_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim myButton As Button  ' here I want to set myButton equal to sender.  However, sender is of type Object; I need to cast
                                        ' sender to a Button and set it to myButton
    Response.Write("<script>alert(" + myButton.CommandArgument + ")</script>")
End Sub

Thanks...
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of martie_11

ASKER

I thought it would be easy : )

Thanks!
Avatar of bman9111
bman9111

Public Sub btnCloseTask_Click(ByVal sender As Object, ByVal e As System.EventArgs)
 Dim myButton As Button = CType(ConversionHelpers.AsWorkaround(sender, GetType(Button)), Button)
 Response.Write("<script>alert(" + myButton.CommandArgument + ")</script>")
End Sub

ran through a converter, basically what timcottee stated... figure I would post it though
Thanks for the post bman9111.

I didn't test Tim's code, but if it doesn't work and yours does, I'll open another Q and give some points to you.

BTW, what converter are you using?