473,748 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I execute Javascript from codebehind...

Hi ,
I register client scripts like this;
--------------------------------------------------------------------------
-----------
Public Sub CreateClientAle rt(ByVal Message As String, ByVal objPage As
Page)
Dim StrScript As New StringBuilder(" ")
With StrScript
.Append("<scrip t type=""text/javascript"">")
.Append(vbCrLf)
.Append(vbCrLf)
.Append("alert( '" & Message & "');")
.Append(vbCrLf)
.Append("</script>")
End With
If Not
objPage.ClientS cript.IsClientS criptBlockRegis tered("AlertBox ") Then
objPage.ClientS cript.RegisterC lientScriptBloc k(Me.GetType,
"AlertBoX", StrScript.ToStr ing)
End If
End Sub
--------------------------------------------------------------------------
-----------
but how can I execute javascipt from codebehind ? ( ex. from buttonclick
event....)
Thanks for all helps...

Hakan Örnek


Feb 13 '07 #1
11 9422
"Hakan ÖRNEK" <or****@gmail.c omwrote in
news:en******** ******@TK2MSFTN GP03.phx.gbl:
but how can I execute javascipt from codebehind ? ( ex. from
buttonclick event....)
Thanks for all helps...
Technically speaking you can't execute Javascript from codebehind. But what
you can do is add a OnClick event handler to the output HTML and allow the
browser to execute javascript when the button is clicked :-)
So, in your button, add an "OnClick" attribute.
Feb 13 '07 #2
Hakan,

You can using the register script methods set all kind of script on your
page.
However if you want to do a JavaScript Function in that, than you have of
course to include a function in that.
(it will be processed at client side by the way)

http://www.vb-tips.com/dbpages.aspx?...c-d6e69a3128ec

There is more on our website about this.

Cor

"Hakan ÖRNEK" <or****@gmail.c omschreef in bericht
news:en******** ******@TK2MSFTN GP03.phx.gbl...
Hi ,
I register client scripts like this;
--------------------------------------------------------------------------
-----------
Public Sub CreateClientAle rt(ByVal Message As String, ByVal objPage As
Page)
Dim StrScript As New StringBuilder(" ")
With StrScript
.Append("<scrip t type=""text/javascript"">")
.Append(vbCrLf)
.Append(vbCrLf)
.Append("alert( '" & Message & "');")
.Append(vbCrLf)
.Append("</script>")
End With
If Not
objPage.ClientS cript.IsClientS criptBlockRegis tered("AlertBox ") Then
objPage.ClientS cript.RegisterC lientScriptBloc k(Me.GetType,
"AlertBoX", StrScript.ToStr ing)
End If
End Sub
--------------------------------------------------------------------------
-----------
but how can I execute javascipt from codebehind ? ( ex. from buttonclick
event....)
Thanks for all helps...

Hakan Örnek


Feb 13 '07 #3
Hi ,
Thanks for all help. I' ll try with callback events...

Hakan...

"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...
Hakan,

You can using the register script methods set all kind of script on your
page.
However if you want to do a JavaScript Function in that, than you have of
course to include a function in that.
(it will be processed at client side by the way)

http://www.vb-tips.com/dbpages.aspx?...c-d6e69a3128ec

There is more on our website about this.

Cor

"Hakan ÖRNEK" <or****@gmail.c omschreef in bericht
news:en******** ******@TK2MSFTN GP03.phx.gbl...
>Hi ,
I register client scripts like this;
--------------------------------------------------------------------------
-----------
Public Sub CreateClientAle rt(ByVal Message As String, ByVal objPage As
Page)
Dim StrScript As New StringBuilder(" ")
With StrScript
.Append("<scrip t type=""text/javascript"">")
.Append(vbCrLf)
.Append(vbCrLf)
.Append("alert( '" & Message & "');")
.Append(vbCrLf)
.Append("</script>")
End With
If Not
objPage.Client Script.IsClient ScriptBlockRegi stered("AlertBo x") Then
objPage.ClientS cript.RegisterC lientScriptBloc k(Me.GetType,
"AlertBoX", StrScript.ToStr ing)
End If
End Sub
--------------------------------------------------------------------------
-----------
but how can I execute javascipt from codebehind ? ( ex. from
buttonclick
event....)
Thanks for all helps...

Hakan Örnek



Feb 13 '07 #4
and cor, it is correct that we cannot do vbScript.. right?

I've read that in a MS press book.. I just had to verify since I've
had some people disagree with me recently

THanks

-Larry Linson Jr

Feb 14 '07 #5
Larry,

I really don't know, sorry
However, in my idea you should forget VBScript on webbrowser clientside, it
was usable in an ASP page on server side. I hope those people don't mix this
up.

Cor

"Larry Linson" <la***********@ hotmail.comschr eef in bericht
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
and cor, it is correct that we cannot do vbScript.. right?

I've read that in a MS press book.. I just had to verify since I've
had some people disagree with me recently

THanks

-Larry Linson Jr

Feb 14 '07 #6
Larry,

You seem to be a bit mistaken in your assumption. If you google for VBScript
and Clientside, there's tons of stuff available. Case in point...

http://www.tek-tips.com/viewthread.c...1318580&page=7

Bruce

"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Larry,

I really don't know, sorry
However, in my idea you should forget VBScript on webbrowser clientside,
it was usable in an ASP page on server side. I hope those people don't mix
this up.

Cor

"Larry Linson" <la***********@ hotmail.comschr eef in bericht
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
>and cor, it is correct that we cannot do vbScript.. right?

I've read that in a MS press book.. I just had to verify since I've
had some people disagree with me recently

THanks

-Larry Linson Jr


Feb 14 '07 #7

Cor

now why should we forget VB on the clientside?

VB WON THE WAR, IDIOT

WHY DID MICROSOFT THROW THE CROWN TO SUN?

SUN DID NOT WIN, VB WAS THE WORLDS MOST POPULAR LANGUAGE

WHY DID MICROSOFT TAKE A DIVE????

I WILL NOT SURRENDER ANOTHER INCH TO MICROSOFT

VB STICKS AROUND OR ELSE


On Feb 13, 11:09 pm, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
wrote:
Larry,

I really don't know, sorry
However, in my idea you should forget VBScript on webbrowser clientside, it
was usable in an ASP page on server side. I hope those people don't mix this
up.

Cor

"Larry Linson" <larrylinso...@ hotmail.comschr eef in berichtnews:11* *************** ******@v45g2000 cwv.googlegroup s.com...
and cor, it is correct that we cannot do vbScript.. right?
I've read that in a MS press book.. I just had to verify since I've
had some people disagree with me recently
THanks
-Larry Linson Jr- Hide quoted text -

- Show quoted text -

Feb 14 '07 #8
bruce

you really are a fucking idiot aren't you?

IT IS NOT SUPPORTED IN ASP.NET
IT IS NOT SUPPORTED IN ASP.NET
IT IS NOT SUPPORTED IN ASP.NET
IT IS NOT SUPPORTED IN ASP.NET
I HAVE BEEN USING IT IN VB FOR MOTHER FUCKING YEARS, DIPSHIT AND I AM
PISSED OFF THAT ASP.NET DOES NOT SUPPORT IT.

IF ASP.NET _DOES_ SUPPORT VBSCRIPT CLIENTSIDE, THEN I DEMAND THAT
MICROSOFT MAIL ME A NEW EDITION OF ALL OF MY MS PRESS BOOKS BECAUSE I
HAVE IT IN WRITING, FROM MS PRESS THAT VBSCRIPT IS NOT SUPPORTED IN
ASP.NET

AND KILLING CLIENTSIDE VBSCRIPT IS MOTHER FUCKING NOT ACCEPTABLE


On Feb 13, 11:20 pm, "Bruce W. Darby" <kraco...@atcom cast.netwrote:
Larry,

You seem to be a bit mistaken in your assumption. If you google for VBScript
and Clientside, there's tons of stuff available. Case in point...

http://www.tek-tips.com/viewthread.c...1318580&page=7

Bruce

"Cor Ligthert [MVP]" <notmyfirstn... @planet.nlwrote in messagenews:%2* **************@ TK2MSFTNGP05.ph x.gbl...
Larry,
I really don't know, sorry
However, in my idea you should forget VBScript on webbrowser clientside,
it was usable in an ASP page on server side. I hope those people don't mix
this up.
Cor
"Larry Linson" <larrylinso...@ hotmail.comschr eef in bericht
news:11******** **************@ v45g2000cwv.goo glegroups.com.. .
and cor, it is correct that we cannot do vbScript.. right?
I've read that in a MS press book.. I just had to verify since I've
had some people disagree with me recently
THanks
-Larry Linson Jr- Hide quoted text -

- Show quoted text -

Feb 14 '07 #9
Bruce,

I think I am not the only one who only once has used it once at client side.
All scripts in Ajax are in my idea in JavaScript.

(While I have written a lot VBScript for ASP serverside).

I don't even know if it still is working standard in ASPNET.

Cor

"Bruce W. Darby" <kr******@atcom cast.netschreef in bericht
news:f6******** *************** *******@comcast .com...
Larry,

You seem to be a bit mistaken in your assumption. If you google for
VBScript and Clientside, there's tons of stuff available. Case in point...

http://www.tek-tips.com/viewthread.c...1318580&page=7

Bruce

"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
>Larry,

I really don't know, sorry
However, in my idea you should forget VBScript on webbrowser clientside,
it was usable in an ASP page on server side. I hope those people don't
mix this up.

Cor

"Larry Linson" <la***********@ hotmail.comschr eef in bericht
news:11******* *************** @v45g2000cwv.go oglegroups.com. ..
>>and cor, it is correct that we cannot do vbScript.. right?

I've read that in a MS press book.. I just had to verify since I've
had some people disagree with me recently

THanks

-Larry Linson Jr



Feb 14 '07 #10

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

Similar topics

5
2136
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a roundtrip to the server. The codebehind seems to be unaware of select box members populated via javascript. So, I'm having to create my own state management solution, (i.e. rewriting the VIEWSTATE mechanism) to persist the state of these select...
2
2842
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added to it to view additional details about the selected result (a second database query is triggered). I want this second query to pop up in a new window, the way it would if I used "window.open" in javascript. I've added a function in the
1
1996
by: Michael SL | last post by:
Here is my problem. I have a delete record button. I want to prompt the user "Do you really want to delete?". If the user clicks 'OK' then I want to execute the CodeBehind on the server side to accomplish this. How do I do this I think the HtmlButton is probably the desired method. But, how do I get the client side javascript to execute the desired (when needed) the server side codebehind function?
2
1963
by: Ekken Zuiber | last post by:
hiye people, i know this have been ask multipletimes over the past year, but i cant find any here in the new group so here goes.. in my code behind, i'm going to do some validation and use javascript to throw the msg out to them, these errors msg are query from the db 1st, how can i call a javascript function from codebehind. is there any other way besides response.write = "<script></script>" ?? 2nd, can someone recommend me ways i can pass...
4
4123
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 windows to select some items, this is done via window.open, I then return the selected items via the returnValue, when I receive the data back I need to be able to call into a function in my main page codebehind to update the xml.
1
5407
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for that), the popup window will have also a text box and a button. when the User click on the button the value on the textbox will be send back to the textbox on My_WUC. I hope I was clear off what I want to do. I've been searching for some ideas...
4
2795
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users will be uploading files that are between 1 and 2 Meg. in size, and they are not too knowledgeable about computers. I want to disable the form buttons so they can't hit them after they hit the "upload" button. We're trying to prevent them from...
6
1577
by: simon | last post by:
hello, what code would i use to kick off a javascript script after i had registered it? If (Not Page.IsClientScriptBlockRegistered("jsScript")) Then Page.RegisterClientScriptBlock("jsScript", strScript) End If looking to kick off a script from inside a codebehind, but conditionally not on an onClick event.
4
4237
by: archana | last post by:
Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user control.. but if i add javascript in page in which i am adding user control then that javascript is executed properly. i tested by displaying alert message in javascript. can anyone tell
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.