[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

asp.net - call a javascript fumction from a public sub method in server side....

Once a user clicks the the sumbit button that runs on the server

public sub button1_click(ByVal sender as Object, ByVal....

 ' Call a javascript function.....right here
0
GlobaLevel
Asked:
GlobaLevel
  • 2
1 Solution
 
Paul JacksonCommented:
Add an onClientClick attribute to the button in the aspx.

<asp:button id="button1" onClientClick="myjavascriptfunction()" ....
0
 
Paul JacksonCommented:
an overview of the OnClientClick attribute  :

http://www.w3schools.com/aspnet/prop_webcontrol_button_onclientclick.asp
0
 
leakim971PluritechnicianCommented:
the server can't execute javascript on the client side.
why not run the javascript when the user click the submit button ?
0
 
BurniePCommented:
Hi,

You cannot execute a javascript directly when you are on the server, but you can tell the browser to execute a javascript function once it returns back.

You can do it using :

ClientScript.RegisterClientScriptBlock(Me.[GetType](), "Anything", "<script type='text/javascript'>MyFunction();</script>")

Once the request goes back to the client, MyFunction() will be executed.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now