Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > script language = "js", "jscript", "javascript", "vj#" What to use

Reply
Thread Tools

script language = "js", "jscript", "javascript", "vj#" What to use

 
 
=?Utf-8?B?UkZTNjY2?=
Guest
Posts: n/a
 
      10-27-2005
Hello,

I would like to use variables with a type in jscript.NET.
I declare them as follows:
var x : double = 5.03;

This doesn't work in my script, that I write to the page in codebehind with
"registerClientScriptBlock" as follows:
string script = "<script language=jscript>";
script += "function test()";
script += ...
Page.RegisterClientScriptBlock("usefulName", script);

I can only use untyped variables like "var x = 5;" in these scripts what is
not useful for me.


For each function in the registered script block, I add an onclick-event to
a webcontrol button:
button1.Attributes.Add("OnClick", "return function1();");

This works when using the statement <script language="jscript"> in the
script block that I want to write to the page with
"Page.RegisterClientScriptBlock"

But when I change the script language to "js", the functions are not called
anymore when I click the corresponding buttons. An error message appears,
that an object does not exist. But with "js" as script language, I can use
variables with a type.
The same with the "vj#"-tag

With the one tag (vj#, js) , I can use variables with a type, but call no
functions,
with an other tag (jscript, the one I am using), I can call the functions,
but use no typed variables.
I need both "features", so I hope, somebody can tell me what I'm doing wrong.
As variables with a type are only available since jscript.NET, I don't know,
if
<script language="jscript"> specifies jscript.NET.

I hope somebody can help.

Thanks in advance & kind regards

RFS666


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U3JlZWppdGggUmFt?=
Guest
Posts: n/a
 
      10-27-2005
not sure if you are getting a bit confused abt the client side and server
side programming..

the jscript.net is for server side programming... the code should be either
in <script language=jscript runat=server> block or in a code behind page...


"RFS666" wrote:

> Hello,
>
> I would like to use variables with a type in jscript.NET.
> I declare them as follows:
> var x : double = 5.03;
>
> This doesn't work in my script, that I write to the page in codebehind with
> "registerClientScriptBlock" as follows:
> string script = "<script language=jscript>";
> script += "function test()";
> script += ...
> Page.RegisterClientScriptBlock("usefulName", script);
>
> I can only use untyped variables like "var x = 5;" in these scripts what is
> not useful for me.
>
>
> For each function in the registered script block, I add an onclick-event to
> a webcontrol button:
> button1.Attributes.Add("OnClick", "return function1();");
>
> This works when using the statement <script language="jscript"> in the
> script block that I want to write to the page with
> "Page.RegisterClientScriptBlock"
>
> But when I change the script language to "js", the functions are not called
> anymore when I click the corresponding buttons. An error message appears,
> that an object does not exist. But with "js" as script language, I can use
> variables with a type.
> The same with the "vj#"-tag
>
> With the one tag (vj#, js) , I can use variables with a type, but call no
> functions,
> with an other tag (jscript, the one I am using), I can call the functions,
> but use no typed variables.
> I need both "features", so I hope, somebody can tell me what I'm doing wrong.
> As variables with a type are only available since jscript.NET, I don't know,
> if
> <script language="jscript"> specifies jscript.NET.
>
> I hope somebody can help.
>
> Thanks in advance & kind regards
>
> RFS666
>
>

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      10-27-2005
This is client side script. I don't know if possible but even though it
would run only if the browser has .NET installed. IMO stick to javascript
for client side scripting...

Found :

Although browsers support most JScript .NET features, the new features that
target the .NET Framework, class-based objects, data types, enumerations,
conditional compilation directives, and the const statement, are supported
only on the server-side. Consequently, you should use these features
exclusively in server-side scripts.

So it looks like this is javascript client side and Jscript.NET server
side...

--
Patrice

"RFS666" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Hello,
>
> I would like to use variables with a type in jscript.NET.
> I declare them as follows:
> var x : double = 5.03;
>
> This doesn't work in my script, that I write to the page in codebehind

with
> "registerClientScriptBlock" as follows:
> string script = "<script language=jscript>";
> script += "function test()";
> script += ...
> Page.RegisterClientScriptBlock("usefulName", script);
>
> I can only use untyped variables like "var x = 5;" in these scripts what

is
> not useful for me.
>
>
> For each function in the registered script block, I add an onclick-event

to
> a webcontrol button:
> button1.Attributes.Add("OnClick", "return function1();");
>
> This works when using the statement <script language="jscript"> in the
> script block that I want to write to the page with
> "Page.RegisterClientScriptBlock"
>
> But when I change the script language to "js", the functions are not

called
> anymore when I click the corresponding buttons. An error message appears,
> that an object does not exist. But with "js" as script language, I can use
> variables with a type.
> The same with the "vj#"-tag
>
> With the one tag (vj#, js) , I can use variables with a type, but call no
> functions,
> with an other tag (jscript, the one I am using), I can call the functions,
> but use no typed variables.
> I need both "features", so I hope, somebody can tell me what I'm doing

wrong.
> As variables with a type are only available since jscript.NET, I don't

know,
> if
> <script language="jscript"> specifies jscript.NET.
>
> I hope somebody can help.
>
> Thanks in advance & kind regards
>
> RFS666
>
>



 
Reply With Quote
 
=?Utf-8?B?UkZTNjY2?=
Guest
Posts: n/a
 
      10-28-2005
Ok,

thanks for your replies. Now, I'm sure, that I use clientside scripting.
The codebehind file is in C#, but I've read that this is also called
"serverside scripting". This is very confusing for me, as I didn't consider
C# as a scripting language. I think it depends on the perspective. I should
mention that this is my first project with a scripting language. Ok, let's
go...

There are three ways to use clientside script (I think):
in <script> </script> block in an aspx-page or in a separate .js-file with
<script src="filename.js"> (in the aspx-page too) or dynamically created in
codebehind with Page.RegisterClientScriptBlock or Page.RegisterStartupScript.
I use the second and the third.

The third brings me to the following problem.
I need a double value in a jscript-variable, whose value I comes from a
codebehind double-value as follows.
script += "<script language=jscript>"
.....
script += "var aDouble = " + "\"" + aDoubleFromCodbehind + "\"" + ";";
.....
Page.RegisterClientScriptBlock("usefulName", script);

The problem is, that this assignment implicitly casts the double value that
comes from codebehind to a string. If I omit the two "\"", I receive an error
message on page_load:
Error: identifier expected

I also tried a conversion with:
script += "var aDouble = (Number)" + "\"" + aDoubleFromCodebehind + "\"" +
";";
but this gives me the following error message:
Error: ';' expected.

I can't believe, that explicit casting is not possible at client side.

So, I hope, somebody can bring some clearance into this

Thanks in advance & best regards

RFS666

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      10-28-2005
If your double value holds 2.5 you'll want to create the following ligne :

var aDouble=2.5;

So just suppress the double quotes for a start...

--
Patrice

"RFS666" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Ok,
>
> thanks for your replies. Now, I'm sure, that I use clientside scripting.
> The codebehind file is in C#, but I've read that this is also called
> "serverside scripting". This is very confusing for me, as I didn't

consider
> C# as a scripting language. I think it depends on the perspective. I

should
> mention that this is my first project with a scripting language. Ok, let's
> go...
>
> There are three ways to use clientside script (I think):
> in <script> </script> block in an aspx-page or in a separate .js-file with
> <script src="filename.js"> (in the aspx-page too) or dynamically created

in
> codebehind with Page.RegisterClientScriptBlock or

Page.RegisterStartupScript.
> I use the second and the third.
>
> The third brings me to the following problem.
> I need a double value in a jscript-variable, whose value I comes from a
> codebehind double-value as follows.
> script += "<script language=jscript>"
> ....
> script += "var aDouble = " + "\"" + aDoubleFromCodbehind + "\"" + ";";
> ....
> Page.RegisterClientScriptBlock("usefulName", script);
>
> The problem is, that this assignment implicitly casts the double value

that
> comes from codebehind to a string. If I omit the two "\"", I receive an

error
> message on page_load:
> Error: identifier expected
>
> I also tried a conversion with:
> script += "var aDouble = (Number)" + "\"" + aDoubleFromCodebehind + "\"" +
> ";";
> but this gives me the following error message:
> Error: ';' expected.
>
> I can't believe, that explicit casting is not possible at client side.
>
> So, I hope, somebody can bring some clearance into this
>
> Thanks in advance & best regards
>
> RFS666
>



 
Reply With Quote
 
=?Utf-8?B?UkZTNjY2?=
Guest
Posts: n/a
 
      10-28-2005
I think, I found out what the problem with:
script += "var aDouble = " + aDoubleFromCodebehind + ";";
is:
After receiving the error message and starting the debug mode, I realized,
that the double value contains a comma instead of a point: 0,8 instead of
0.8. But the double variable in codebehind contains a point, so where comes
the comma from? I cannot influence it.
Could it have something to do with the codepage of the aspx-file?

Thanks & regards

RFS666
 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      10-28-2005
"RFS666" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I can't believe, that explicit casting is not possible at client side.


It's not - JavaScript (like VBScript) has only only type of variable:
variant.

> So, I hope, somebody can bring some clearance into this


var dblTest1 = "100.12";
var dblTest2 = "10.1";

alert(parseFloat(dblTest1) * parseFloat(dblTest2));


 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      10-28-2005
Don't worry was expected Now that I'm sure that you don't work with the
decimal point, let's proceed with the next step :

DoubleValue.ToString(System.Globalization.Curlture Info.InvariantCulture)
(of course you can do an import to shorten the expression).

It will write down the value with the decimal point instead of a comma.

The problem is that as soon as you write down values such as decimal and/or
date, the text representation depends on national settings. The default
culture is defined in the web.config file and is suitable for displaying
data unlike programming languages. The InvariantCulture allows to avoid
using the current national setting...

--
Patrice

"RFS666" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> I think, I found out what the problem with:
> script += "var aDouble = " + aDoubleFromCodebehind + ";";
> is:
> After receiving the error message and starting the debug mode, I realized,
> that the double value contains a comma instead of a point: 0,8 instead of
> 0.8. But the double variable in codebehind contains a point, so where

comes
> the comma from? I cannot influence it.
> Could it have something to do with the codepage of the aspx-file?
>
> Thanks & regards
>
> RFS666



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
Python as active script <script language=python> misterdi Python 0 07-28-2009 04:30 PM
JSP problem: <script language="JavaScript"> '<%=expression%>' </script> Edward Java 1 04-03-2006 06:15 PM
Use of type and/or language in script-tag Erwin Moller Javascript 7 03-05-2004 04:49 AM



Advertisments