[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2011-02-20
4
Medium Priority
?
263 Views
Last Modified: 2012-05-11
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
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 34939641
Add an onClientClick attribute to the button in the aspx.

<asp:button id="button1" onClientClick="myjavascriptfunction()" ....
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 34939650
an overview of the OnClientClick attribute  :

http://www.w3schools.com/aspnet/prop_webcontrol_button_onclientclick.asp
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34939675
the server can't execute javascript on the client side.
why not run the javascript when the user click the submit button ?
0
 
LVL 16

Accepted Solution

by:
BurnieP earned 2000 total points
ID: 34939947
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question