By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

Calling Javascript Function from within VB Procedure?

P: n/a
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My
code is something like this:

VB Code:
Public Sub VBProcedure()
..
..
Run some VB Code...
..
..
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was just
a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin

Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Cor
Hi Martin,

The most simple sample.

\\\
Dim str As String
str = "<script language=javascript> {window.open('http://www.google.com');}
</script>"
RegisterStartupScript("Startup", str)
///

I hope this helps a little bit?

Cor
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My code is something like this:

VB Code:
Public Sub VBProcedure()
.
.
Run some VB Code...
.
.
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was just a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin

Nov 20 '05 #2

P: n/a

Hi Cor

Thanks for your message.
Well, I'm not exactly sure whether that's the answer to my problem. After
having had a look at the RegisterScript Methods, it seems to me that it is
just a convenient way to inject the Javascript into the page. I can do this
by writing it directly in the HTML view in VS. Or is there a difference.
Once having the Javsscript registered, I still need a HTML button on my page
whick calls the Javascript in the OnClick Event.

However in my case, I'm calling a VB Sub with the OnItemCommand Event of the
Datagrid to look up some data depending on the value choosen nin the
datagrid. So the OnItemCommand for the datagrid is already taken. At the
same time when the OnItemCommand Event fires I also would like to execute a
client-side Javascript function after the data has been looked up.
So I thought I'm calling the Javascript from within the VB Sub in which I
look up the data after completion of look-up.

Any possible way to achive this?

Thanks for your help & efforts!

Kind Regards,

Martin

"Cor" <no*@non.com> wrote in message
news:#M**************@tk2msftngp13.phx.gbl...
Hi Martin,

The most simple sample.

\\\
Dim str As String
str = "<script language=javascript> {window.open('http://www.google.com');} </script>"
RegisterStartupScript("Startup", str)
///

I hope this helps a little bit?

Cor
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible?

My
code is something like this:

VB Code:
Public Sub VBProcedure()
.
.
Run some VB Code...
.
.
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was

just
a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin


Nov 20 '05 #3

P: n/a
Hi Cor

Thanks for your message.
Well, I'm not exactly sure whether that's the answer to my problem. After
having had a look at the RegisterScript Methods, it seems to me that it is
just a convenient way to inject the Javascript into the page. I can do this
by writing it directly in the HTML view in VS. Or is there a difference.
Once having the Javsscript registered, I still need a HTML button on my page
whick calls the Javascript in the OnClick Event.

However in my case, I'm calling a VB Sub with the OnItemCommand Event of the
Datagrid to look up some data depending on the value choosen nin the
datagrid. So the OnItemCommand for the datagrid is already taken. At the
same time when the OnItemCommand Event fires I also would like to execute a
client-side Javascript function after the data has been looked up.
So I thought I'm calling the Javascript from within the VB Sub in which I
look up the data after completion of look-up.

Any possible way to achive this?

Thanks for your help & efforts!

Kind Regards,

Martin

"Martin Feuersteiner" <th************@hotmail.com> wrote in message
news:c1**********@sparta.btinternet.com...
Dear Group

I'm using VB to write an aspnet application. I would like to call a
javascript function from within a VB Sub or VB Function, is it possible? My code is something like this:

VB Code:
Public Sub VBProcedure()
.
.
Run some VB Code...
.
.
Now call the javascript function

End Sub
------------------------------------------------------
javascript:
<HEAD>
<script language=javascript>
<!--
// MyFunction
function myfunction() {
window.open()
}
//-->
</script>
</HEAD>

I tried javascript: myfunction() within the VB procedure. Well, it was just a blind guess since the 'javascript:' syntax did not produce any errors.
What is 'javascript:' all about? I can't find it documented.

Thanks for your help & efforts!

Martin

Nov 20 '05 #4

P: n/a
Cor
Hi Martin,

I said that was the simplest one. And I have not direct the answer to your
datagrid, but look also look at this sample (you have to find the postback
event from the datagrid, than I think this will work than also).

\\\A webform with an imagebutton and two bitmaps in the solution map
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.ImageButton1.ImageUrl = "bitmap2.bmp"
Me.ImageButton1.Attributes("onmouseover") = "this.src='bitmap1.bmp';"
Me.ImageButton1.Attributes("onmouseout") = "this.src='bitmap2.bmp';"
Me.ImageButton1.Attributes("onClick") = _
"window.location='mailto:no*@non.com?subject=C or demo&body=I hope this
helps?';"
End Sub
///

I hope this helps a little bit?

Cor
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.