473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

asp.net SS Control Call Client Java Function

Can an asp.net button that is a server side control call a client side java
function when the button is clicked? If so, please provide
example.....thanks.,
Jul 21 '05 #1
1 1422
A server side button itself cant trigger the javascript, but the client code
it generates can - see the code below

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Mike Moore" <Mi*******@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
Can an asp.net button that is a server side control call a client side java function when the button is clicked? If so, please provide
example.....thanks.,

<html>
<head>
<script language="VB" runat="server">

Sub Page_Load( sender as Object,e as EventArgs)
'Form the script that is to be registered at client side.
Dim scriptString as String = "<script language=JavaScript> function
onClientClick() {"

ScriptString += "var retVal = window.confirm('Click OK to continue.
Click Cancel to stop.');"
ScriptString += "window.alert(retVal);"
ScriptString += "if (retVal){"
ScriptString += "window.alert('MVP Code is doing the Postback!');"
ScriptString += "return true;"
ScriptString += "}"
ScriptString += "else"
ScriptString += "{"
ScriptString += "window.alert('MVP Code is NOT Doing the
Postback!');"
ScriptString += "return false;"
ScriptString += "}"
ScriptString += "}<"
scriptString += "/"
scriptString += "script>"

If(Not IsClientScriptBlockRegistered("clientScript"))
RegisterClientScriptBlock("clientScript", scriptString)
End If
End Sub
Sub button_onClick( sender as Object,e as EventArgs)
Response.Write("Postback as requested!!!" + DateTime.Now())
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="OK" onserverclick="button_onClick"
onclick="if(!onClientClick()){return false;}"
runat="server">

</form>
</body>
</html>
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Marina | last post by:
Hi, I am trying to find the minimum security settings to allow a windows control embedded in IE have full trust. If I give the entire Intranet zone full trust, this works. However, this is...
4
by: Barb | last post by:
I have a user control as my Save button for my page. When the Save button is clicked, I want some client-side validation to take place from a javascript function in the page, and then I'd like the...
3
by: Ant | last post by:
I'm building a Web user control that has several public functions. Can I fire them from the client side? for example Javascript and an HTML button
4
by: Rob Shorney | last post by:
Hi, I am using .Net 2003 , c# asp.net. The situation i have is this. I have a asp.net page which in the codebehind maintains an xml document in memory. The user can click on a button to popup a...
4
by: Mike Moore | last post by:
Can an asp.net button that is a server side control call a client side java function when the button is clicked? If so, please provide example.....thanks.,
2
by: Shawn | last post by:
Hi. I've never created an ActiveX control before, so I know little about what it is capable of and what its limitations are. My problem is this: I have to create a way to send multiple documents...
7
by: J-T | last post by:
I have a user control called "Test1" with two button on it ,one is input and the other one is a server control as follow: <input type="button"...
1
by: Mike Moore | last post by:
Can an asp.net button that is a server side control call a client side java function when the button is clicked? If so, please provide example.....thanks.,
4
by: =?Utf-8?B?S2F1c2hhbCBNZWh0YQ==?= | last post by:
Hi, I was reading about asynchronous transfer of control in Real Time Java Specification. I am wondering if there is any way we can do similar thing with Web Services in Service Oriented...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.