473,734 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
"registerClient ScriptBlock" as follows:
string script = "<script language=jscrip t>";
script += "function test()";
script += ...
Page.RegisterCl ientScriptBlock ("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.Attribu tes.Add("OnClic k", "return function1();");

This works when using the statement <script language="jscri pt"> in the
script block that I want to write to the page with
"Page.RegisterC lientScriptBloc k"

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="jscri pt"> specifies jscript.NET.

I hope somebody can help.

Thanks in advance & kind regards

RFS666
Nov 19 '05 #1
7 3288
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=jscrip t 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
"registerClient ScriptBlock" as follows:
string script = "<script language=jscrip t>";
script += "function test()";
script += ...
Page.RegisterCl ientScriptBlock ("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.Attribu tes.Add("OnClic k", "return function1();");

This works when using the statement <script language="jscri pt"> in the
script block that I want to write to the page with
"Page.RegisterC lientScriptBloc k"

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="jscri pt"> specifies jscript.NET.

I hope somebody can help.

Thanks in advance & kind regards

RFS666

Nov 19 '05 #2
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" <RF****@discuss ions.microsoft. com> a écrit dans le message de
news:0D******** *************** ***********@mic rosoft.com...
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 "registerClient ScriptBlock" as follows:
string script = "<script language=jscrip t>";
script += "function test()";
script += ...
Page.RegisterCl ientScriptBlock ("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.Attribu tes.Add("OnClic k", "return function1();");

This works when using the statement <script language="jscri pt"> in the
script block that I want to write to the page with
"Page.RegisterC lientScriptBloc k"

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="jscri pt"> specifies jscript.NET.

I hope somebody can help.

Thanks in advance & kind regards

RFS666

Nov 19 '05 #3
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.j s"> (in the aspx-page too) or dynamically created in
codebehind with Page.RegisterCl ientScriptBlock or Page.RegisterSt artupScript.
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=jscrip t>"
.....
script += "var aDouble = " + "\"" + aDoubleFromCodb ehind + "\"" + ";";
.....
Page.RegisterCl ientScriptBlock ("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)" + "\"" + aDoubleFromCode behind + "\"" +
";";
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

Nov 19 '05 #4
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" <RF****@discuss ions.microsoft. com> a écrit dans le message de
news:C6******** *************** ***********@mic rosoft.com...
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.j s"> (in the aspx-page too) or dynamically created in codebehind with Page.RegisterCl ientScriptBlock or Page.RegisterSt artupScript. 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=jscrip t>"
....
script += "var aDouble = " + "\"" + aDoubleFromCodb ehind + "\"" + ";";
....
Page.RegisterCl ientScriptBlock ("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)" + "\"" + aDoubleFromCode behind + "\"" +
";";
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

Nov 19 '05 #5
"RFS666" <RF****@discuss ions.microsoft. com> wrote in message
news:C6******** *************** ***********@mic rosoft.com...
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(parseFloa t(dblTest1) * parseFloat(dblT est2));
Nov 19 '05 #6
I think, I found out what the problem with:
script += "var aDouble = " + aDoubleFromCode behind + ";";
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
Nov 19 '05 #7
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.ToS tring(System.Gl obalization.Cur ltureInfo.Invar iantCulture)
(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 InvariantCultur e allows to avoid
using the current national setting...

--
Patrice

"RFS666" <RF****@discuss ions.microsoft. com> a écrit dans le message de
news:83******** *************** ***********@mic rosoft.com...
I think, I found out what the problem with:
script += "var aDouble = " + aDoubleFromCode behind + ";";
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

Nov 19 '05 #8

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

Similar topics

7
12498
by: Rune Strand | last post by:
What would it take to create a Firefox extension that enables Python as a script language in the browser - just like Javascript? Is it at all possible? Are the hundred good reasons not to bother? I once made an application that used MozPython. It was fun and very fast compared to the Mod_Python I eventually replaced it with. I had to, because of all the mess updating Mozilla caused. ActiveState has a project too . But none of these can...
5
1554
by: Services of TKO | last post by:
Hi, On witch website i can find the whole script language of C++? I want to learn to program with C++ but i can't find a list of script language and what that script does (description). Can you recommand a website? Thank you for your help and time. Greetings TKO services
13
16979
by: Elmo Watson | last post by:
I have IIS installed on my computer (XP pro) - - I have the DotNet Framework installed - - ASP.net runs fine - but any time I run even the simplest Classic ASP script/page, I get the following error: Active Server Pages error 'ASP 0201' Invalid Default Script Language The default script language specified for this application is invalid.
2
1587
by: Ingo Schasiepen | last post by:
Hi there, i'm evaluating if c# is suited to replace a script language. Most of the elements of this language can be replaced with a c#-library, but it also has some realtime-like elements. E.g., in this language, the following code is possible: { Int32 i=0; OnEvent ( ... ) {
5
1477
by: Piotr 'Zenobius' Baranowski | last post by:
Hello I'm new to programming under C#. I have question about suggestions, how to write a simple script language, that can handle operations like 'if' statement. Whats better, operating on variables , or maybe predefined functions
4
2246
vikas251074
by: vikas251074 | last post by:
Hello everybody, Should I use script language attribute or script type? Is there any difference? Until now I have used script language attribute in my all programme where javascript has to be used. Thanks and regards, Vikas
8
5065
by: howa | last post by:
Just found a funny things.. in HTML4's dtd, http://www.w3.org/TR/html4/strict.dtd language is not valid, i.e. <!ELEMENT SCRIPT - - %Script; -- script statements --> <!ATTLIST SCRIPT charset %Charset; #IMPLIED -- char encoding of linked resource --
14
1694
by: dark100 | last post by:
Hi All! I have been developing an embedded macro script language (called gmac) for some time, and I would like to ask your opinion about it. Here is a quote from the introduction part (in the readme): Gmac is more like an embedded script language (like JavaScript), than a common macro preprocessor. You can execute small scripts enclosed in ''. These scripts are executed by gmac. Other parts of the input are left unchanged....
4
10045
by: lenniekuah | last post by:
Hi Helpful Good Guys, I need your help. Please help me. I have been asked to transfer the FUNCTION FCalculate from WebFrmLoan.aspx to Web Page CODEBEHIND. The Functon event is to calculate the Loan Monthly Repayment amount. I have not done it before using VBScript and it generated this error message. Option Strict On requires all Function, Property, and Operator declarations to have an 'As' clause.
0
8946
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
8776
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
9310
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...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
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
6735
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
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3261
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
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.