Solved

how can asp call js function?

Posted on 2007-11-15
7
427 Views
Last Modified: 2012-08-13
i mean with no user help...no links no actions...
<input type="button" value="Click Me!" onclick="getData()" />

just want add inside of some if a code that will call js function
0
Comment
Question by:sasha85
7 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20288139
you can still have javascript sections in asp pages, i.e.

<script language="javascript">
 function getData() {
   // js code
 }
</script>

and referenced in your html  <input type="button" value="Click Me!" onclick="getData()" />
0
 
LVL 11

Expert Comment

by:Sven
ID: 20288146
You can only transmit data with reloading page and using querystring or by posting the data to the server (AJAX).
0
 

Author Comment

by:sasha85
ID: 20288167
you mean:
if x=y then
js1...
else
js2
end if
?

do you know where i can find a good ajax\ajaxed example that i can view its code and make some changes?
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 11

Accepted Solution

by:
Sven earned 350 total points
ID: 20288176
I think I missunderstood your question ;)

As imitchie said you can use a code like the following:
<%
If x = y Then
  %>
  <script language="javascript">
  <!--
  alert('1');
  //-->
  <%
Else
  %>
  <script language="javascript">
  <!--
  alert('2');
  //-->
  <%
End If
%>

Open in new window

0
 

Author Comment

by:sasha85
ID: 20288203
what did you mean with the ajax?
somehow always when i find a nice short code of ajax on the web and i copy it to my computer
i got "ajaxed is undefined' do you know why can it be?
0
 
LVL 11

Expert Comment

by:Sven
ID: 20288222
I thought you would set data of the client javascript to asp.

If you copy Ajax-code you also need the included framework (like prototype.js). Please post another question for this with code examples!
0
 
LVL 5

Expert Comment

by:pavaneeshkumar
ID: 20288376
<input type="button" value="Click Me!" onclick="getData()" /> change this line to

<input type="button" value="Click Me!" onclick="getData();" />

see this code Snippet
<html><title>hello js</title>
<script type="text/javascript">
 
function hello()
{
	alert("Hello from button click");
}
</script>
 
<body>
 
<form>
<input type="button" value="CodingForums" onClick="hello();" />
</form>
</body>

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

791 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