Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been working on "Using JavaScript Along with vb.net" where i'm trying to incorporate java script code in vb.net windows application.

in the script i'm trying to invoke a function Alert hello() on button click action

the exception i'm getting is Attributes is not a member of systems.windows.forms.button

below is the code i'm using in the application

What I have tried:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Page.RegisterStartupScript("MyScript", _
"<script language=javascript>" & _
"function AlertHello() { alert('Hello ASP.NET'); }</script>")

Button1.Attributes("onclick") = "AlertHello()"
Button2.Attributes("onclick") = "AlertHello()"
End Sub
Posted
Updated 8-Sep-16 22:45pm

Not Possible at all, both are of different platforms
use MessageBox.Show() to display the alert box.
if you want to run javascript in server side then look into Node.js[^]
 
Share this answer
 
Um.
You do realize that WinForms apps don't have "pages", don't run in a browser, and have nothing to do with Javascript or scripts in general?

Where did you get the idea that you could just lift web-based code from a site and it would work in your Windows based application?
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900