Re: can run javascript can't run vbscript - WHY
From: Jared (ask_me_for_it_at_nospam.com)
Date: 10/11/04
- Next message: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Previous message: JAPHET: "Please Help Using Custom web Control !!!!."
- In reply to: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Next in thread: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Reply: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 11 Oct 2004 08:52:18 -0500
Scott,
First, I'm not try to "blast" you, but, if you leave a post that has no
explanation of why you believe a certain area is the root of the problem you
need to state it. I can come off a little harsh when I don't see any
reasoning behind the posts, for that, I apologize. It's not my intention to
get in a shouting match with others, It's a pet-peeve of mine that causes
the "rough" comments, people need to learn from the mistakes they and others
make, to make us all better at what we do. If you know the secret of
happiness/world peace/hunger (you pick a topic), but are unwilling to share,
how will other implement/learn from the knowledge?
>>>>> Change the VBScript so that your function is "Sub...End Sub", not
>>>>> "function...end function".
Put yourself in Duncan's shoes, what in this comment would make him believe
this to is the resolution to the problem? Remember, this is all that you
supplied him. How will Duncan and others (myself included) LEARN from this?
Where is your reasoning? Why do you believe this to be the problem? What
will stop him/us from making the same mistakes in future applications
assuming this is the problem?
> It is a method of the window object in the BOM (browser object model,
> varies from browser to browser) not the DOM (Document Object Model, set by
> the W3C, describes how to programmatically access parts of a markup
> document [html or xml] without knowing or caring which is being used).
This is why I said "I think", I don't want to come off as authoritative on
something I really do not know, I'm not trying to pass myself off as a guru,
or an expert in anything, I am only trying to help and learn in the process.
That is whole point of this newsgroup, If the other developers only wanted
answers they could use sites like experts-exchange, where people are quick
to give a fix, and don't explain the reasoning.
> It may well have been the case since depending on what browser/version he
> is using, the VBScript Interpreter may choke on a function that does not
> assign itself a value. This is what I was warning him of.
You should have stated this in your original post, I would even go as far as
to reference to this if you know of one.
i.e. IE 4 with WSH 1.0 fail...
>> What did I say that would insinuate I believed this to be server side
>> code?
> You said: "The problem is he is trying to use a vbscript msgbox call in a
> web form." VBScript is client-side, but web forms are server-side.
> Regardless, based on the OP's code, he clearly wrote client-side code in
> VBScript, and under those conditions, the use of msgbox() is absolutley
> correct and is not the cause of his problem as you stated.
I think you are confusing my response with a response post later. The
original post, it has no mention of runat=server in any source lines. Thus,
I made no mention of server side code and was trying to help troubleshoot on
the client side. By stating web form, one can't assume that all
processing/formatting is done on the server, I think you just misunderstood
me.
Duncan stated:
> I changed the test vbscript to
> sub vbtest(sender AS Object, e AS EventArgs)
> lbErrorMessage.text = "VB Test" end sub
He went on to state that this worked, but, he didn't understand why it won't
work in the client side, this is where the server-side discussion started.
Now the method has changed entirely, it is no longer a popup, but a property
set operation. How can you state that this fixed the problem if the method
changed? He also stated that his original problem was still NOT working.
> Jared, did you read my response to you and the OP? Instead of blasting me
> for trying to clarify what the OP's problem/solution is and letting you
> know about the inacurracy of your diagnosis of the problem ("The problem
> is he is trying to use a vbscript msgbox call in a web form."), you could
> maybe go on to read the last piece of what I wrote, which is the correct
> root of the problem and correct solution for it.
Pot calling the kettle black?
First, I did state in my last post that I was completely wrong about the
VBScript msgbox, so that can be put to rest. Regardless, he is using IE 6.0
which I am using and the test page (.html) I wrote works as expected, using
a client-side button handler and an
call, both use the same Function-End Function syntax and both produce the
expected results. Do you have any other solutions for Duncan?
Jared
----------------------------------------------------
"Scott M." <s-mar@nospam.nospam> wrote in message
news:%23ZooSixrEHA.3748@TK2MSFTNGP09.phx.gbl...
>
> "Jared" <ask_me_for_it@nospam.com> wrote in message
> news:10mjc171ronir90@corp.supernews.com...
>> Scott,
>> I know how sub and function work, that wasn't the point I was trying
>> to make, if you leave the call function end function it will still work
>> assuming the code in the call is correct. While I thought for sure I have
>> tried to use the msgbox function to create a popup in previous apps I
>> tried it and find that it does work. This is why I originally recommended
>> using the alert method of the window object in the first place. Also, you
>> noted that alert has no meaning in vbscript. I agree, nor does it in
>> javascript. It is part of the window object in the HTML DOM (I think).
>
> It is a method of the window object in the BOM (browser object model,
> varies from browser to browser) not the DOM (Document Object Model, set by
> the W3C, describes how to programmatically access parts of a markup
> document [html or xml] without knowing or caring which is being used).
>
>>The script block allows us to access these methods. I would still use the
>>alert method from within a vbscript tagged script block. My original point
>>was you told Duncan that his entire problem was the fact that he used
>>function end function, which is not the case,
>
> It may well have been the case since depending on what browser/version he
> is using, the VBScript Interpreter may choke on a function that does not
> assign itself a value. This is what I was warning him of.
>
>>what if he wanted to return the results of the msgbox to one function, but
>>not another? Do you propose he create two separate methods?
>
> No, I would recommend having one function that returns a value and then a
> calling line of code could choose to use the return value or not. But
> having a function that does not return a value is incorrect usage of the
> Function...End Function syntax and in some circumstances CAN cause an
> error. This is what I was indicating. This is a matter of proper coding
> and not a matter of what's easiest to do.
>
>>While I agree that he should be using sub, do you dispute the fact that it
>>will not fix his problem?
>
>>As stated above, in some browsers it could very well be the source of the
>>problem.
>
>> Have you tried to use the alert method in a vbscript function call? Try
>> it and get back with me, does it work?. What did I say that would
>> insinuate I believed this to be server side code?
>
> You said: "The problem is he is trying to use a vbscript msgbox call in a
> web form." VBScript is client-side, but web forms are server-side.
> Regardless, based on the OP's code, he clearly wrote client-side code in
> VBScript, and under those conditions, the use of msgbox() is absolutley
> correct and is not the cause of his problem as you stated.
>
>> Scott, did you read my response to Duncan?
>
> Jared, did you read my response to you and the OP? Instead of blasting me
> for trying to clarify what the OP's problem/solution is and letting you
> know about the inacurracy of your diagnosis of the problem ("The problem
> is he is trying to use a vbscript msgbox call in a web form."), you could
> maybe go on to read the last piece of what I wrote, which is the correct
> root of the problem and correct solution for it.
>
> ==============
> Your problem is that you are trying to mix client-side and server-side
> code,
> you are trying to mix JavaScript and VBScript and VB.NET languages.
>
> From an HTML hyperlink, you don't call a vbscript method as you have
> indicated(test), you do it like this: <A
> HREF="#" onClick="test">test</A>. But, even this won't solve your problem
> because you are trying to get a client-side element to fire a server-side
> event and this is a no-no.
>
> What you will need to do is set a "flag" on the client side, submit the
> form
> and during the server processing of the form's postback, check for the
> existence of the flag. If the flag is present, you can run a particular
> server event.
> ==================
>
>
>
>>
>> Jared
>>
>> "Scott M." <s-mar@nospam.nospam> wrote in message
>> news:Ono7wavrEHA.4004@TK2MSFTNGP10.phx.gbl...
>>> Jared,
>>>
>>> In VB 6.0/VBScript/VB.NET you use Function...End Function when your
>>> method is going to return a value, you use Sub...End Sub when your
>>> method is not going to return a value. If you use Function...End
>>> Function and don't assign a return value to the function, then in the VB
>>> world, you are making a Sub.
>>>
>>> Since the OP's method does not return a value, he should be using
>>> Sub...End Sub, not Function...End Function.
>>>
>>> As for the use of msgbox:
>>>
>>> The OP has showed us that he is using client-side scripting here, not
>>> server side scripting and he has indicated that he is using VBScript as
>>> the client-side scripting language. While this is not generally
>>> desirable (because only IE supports client-side VBScript), it is
>>> perfectly fine if the target client is known to be IE. Now, in the
>>> VBScript language there IS a msgbox function that produces the box the
>>> OP is looking for. In VBScript, "alert()" has no meaning and would
>>> cause an error if used.
>>>
>>>
>>>
>>> "Jared" <ask_me_for_it@nospam.com> wrote in message
>>> news:10mh5085trmaa93@corp.supernews.com...
>>>> Sub - End Sub is not the problem with this. It can be declared
>>>> function - end function. The problem is he is trying to use a vbscript
>>>> msgbox call in a web form. I explained in another post that the alert
>>>> method is part of DOM and not part of javascript (I could be wrong);
>>>> anyways, the vbscript call should use the alert method as well, and not
>>>> the msgbox call.
>>>>
>>>> "Scott M." <s-mar@nospam.nospam> wrote in message
>>>> news:epUzO6krEHA.1816@TK2MSFTNGP09.phx.gbl...
>>>>> Change the VBScript so that your function is "Sub...End Sub", not
>>>>> "function...end function".
>>>>>
>>>>>
>>>>> "duncan" <dwang@woodace.co.uk> wrote in message
>>>>> news:8fe85207.0410091135.50385a5f@posting.google.com...
>>>>>> why does this work :-
>>>>>>
>>>>>> <HEAD>
>>>>>> .....
>>>>>> <SCRIPT LANGUAGE="javascript">
>>>>>> function test()
>>>>>> {
>>>>>> alert("test 1")
>>>>>> }
>>>>>> </SCRIPT>
>>>>>> ....
>>>>>> </HEAD>
>>>>>> <BODY>
>>>>>> ...
>>>>>> test
>>>>>> .....
>>>>>> </BODY>
>>>>>>
>>>>>> but this does not :-
>>>>>>
>>>>>> <HEAD>
>>>>>> .....
>>>>>> <SCRIPT LANGUAGE="vbscript">
>>>>>> function test()
>>>>>> msgbox("VB Test")
>>>>>> end function
>>>>>> </SCRIPT>
>>>>>> .....
>>>>>> </HEAD>
>>>>>> .....
>>>>>> <BODY>
>>>>>> ...
>>>>>> test
>>>>>> ...
>>>>>> </BODY>
>>>>>>
>>>>>> As you can see the only real difference is I have changed JavaScript
>>>>>> to be vbscript and this is the problem. I don't even get a script
>>>>>> error reported by IE6 when I try to run the VB version. I tried
>>>>>> varying vbscript eg vb, vbs but nothing happens.
>>>>>>
>>>>>> Why can I not run my vb function just like I can Javascript. It
>>>>>> defies logic (or at least mine!! which says a simple name change
>>>>>> should not cause this problem)
>>>>>>
>>>>>> What I am trying to achieve is to run my actual code as a client side
>>>>>> script - with NO postback. I have managed to run some JavaScript
>>>>>> without causing a post back using the <A>...</A> and I can run my vb
>>>>>> actual code from a <ASP:BUTTON> but this causes a postback. I want
>>>>>> to use vb/vbscript as I am familiar with vb and want to get my pages
>>>>>> working asap.
>>>>>>
>>>>>> One very frusttrated newbie (to ASP.NET / VB.NET)
>>>>>>
>>>>>>
>>>>>> Duncan
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
- Next message: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Previous message: JAPHET: "Please Help Using Custom web Control !!!!."
- In reply to: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Next in thread: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Reply: Scott M.: "Re: can run javascript can't run vbscript - WHY"
- Messages sorted by: [ date ] [ thread ]