Asp.Net SS control call client java function

G

Guest

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.,
 
T

Tampa.NET Koder

In code:

button1.Attributes.Add("onClick" , " doSomething()");

doSometing() is your Javascript function

I would write this code probably in the page load event.
 
B

Blue Streak

To register the client side JavaScript (example):

Private Sub Page_Load(sender as Object, e as EventArgs) Handles MyBase.Load
....
ClientScriptKBase()
....
End Sub

....

Private Sub ClientScriptKBase()
'Register JavaScript block for KBase button (HTML Control)
Dim JavaScriptCode as String = "<SCRIPT language='JavaScript'
type='text/javascript'><!--"& vbCRLF _
&"function KBase()"& vbCRLF _
&"{"& vbCRLF _
&"
window.open('../KBase/KBase.aspx','win_KBase','status=1,resizable=1,alwaysRa
ised=1,left=0,top=0,height=' + (screen.availHeight - 110) + ',width=' +
(screen.availWidth - 10));"& vbCRLF _
&"} //--> </SCRIPT>"& vbCRLF

If NOT(IsClientScriptBlockRegistered("KBase")) Then
RegisterClientScriptBlock("KBase", JavaScriptCode)
End If
End Sub
 
T

tshad

Mike Moore said:
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.,

I use the following for my popups:

Dim myDeleteButton As LinkButton
myDeleteButton = e.Item.FindControl("btnDelete")
myDeleteButton.Attributes.Add("onclick", "return confirm('Are you sure
you want to delete this answer?');")

Tom
 
T

Tampa.NET Koder

Hope we are reading your question correctly, do you mean client side
javascript or java ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top