Solved

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

Posted on 2011-02-20
4
260 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 500 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

690 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