Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CodeBehind and JavaScript
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Divers
Thread ID:
00927353
Message ID:
00927479
Vues:
29
Richard,

All you have to do is something like this:
Private Sub btnMyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMyButton.Click
   Dim js As String
   js = "<script language='javascript'> { myJSFunction(); }</script>"
   Response.Write(js)
End Sub
The button is a standard asp.net server control. Sure, the code above is in the code-behind; however, the script function myJSFunction() (or whatever javescript code you run) runs client side.

I do this routinely... it should work for you.

Dino Esposito's book "Programming Microsoft ASP.NET" as well as several other books and web-sites tell you how to do this.

Regards,
Carl

>While interesting, I think your reply is telling me that I won't be able to do what I need... I use the JavaScript to work with the OCX and the OCX is client-side.
>From the sounds of it, I think I'll need to add a HTML button to update my OCX alarm via the client-side JavaScript I am using.
>
>Thanks.
>
>>You have a few options to do this in your code-behind. You could do something like this:
>>
>>
>>Dim js As String
>>js = "<script language='javascript'> { myJSFunction(); }</script>"
>>Response.Write(js)
>>
>>
>>You simply embed the above snippet of code in your codebehind where you need it. In this case a javascript function is called and within that javascript function you can do whatever client side stuff you need.
>>
>>In some cases it may be better to use RegisterClientScriptBlock or RegisterStartupScript. However, for most simple javascript needs I find the above script works well.
>>
>>Regards,
>>Carl.
>>
>>>I thought I had this resolved and then I realized I didn't...
>>>
>>>Is there anyway to call a JavaScript Function from the CodeBehind?
>>>
>>>I have an web form app using an OCX and FRAMES.
>>>The FrameSet has 2 sections, which we'll call Header and Main.
>>>
>>>The Header frame is basically static. In Header I have an OCX alarm control which I can access via a JavaScript... even from the Main frame.
>>>
>>>The Main frame is dynamic and contains my app. Part of my app is a reminder system. It displays to me a record and allows me to update my table by modifying the record and clicking an update button which executes code on the CodeBehind page. After the record is updated, if there is a time in the reminder field, I want to create an entry in the OCX alarm in the Header frame.
>>>
>>>I believe I can do it if I add a sepparate HTML button to give me access to the JavaScript, but I'd rather do it with a function call from inside the CodeBehind Update routine.
>>>
>>>Is this possible or am I wasting my time?
>>>
>>>TIA,
>>>Rick
Carl Olson, Jr.
CEO, Founder
Cerelogic, Inc.

www.cerelogic.com

"Applying rocket science to business."
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform