473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to run a ClientScript Containing a complex function

Hi Guys,

I m an engineering student working on web development project(in asp.net) and i am stuck up with the client side script. Precisly i want to run a complex function(which calculate the Hash of some txt) on client side and send the result back to the server. I have search the web a lot for help, but i could only find some scripts(useless to me) containing functions for poping up messages etc.

Please show me some way out to solve this problem, it will be greate if you give me some example of code showing such client scripts.

Thanks in advance.
Mar 3 '07 #1
5 1219
pronerd
392 Expert 256MB
If all you want to see is how to is send back a value to the server that is calculated on the client side then it would work like this.


<script type="text/javascript">

var someValueToSendBack = null;

// blah blah blah....
// Put your "complex function" here
// blah blah blah....

top.DisplayMenuFrame.location.href = '<<URL_OF_YOUR_SITE>>?paramterName='+someValueToSe ndBack;


</script>
Mar 4 '07 #2
hi dear
its so easy.
i know 3 ways for doing this job

1- use a form with hidden fields,which when your calculation finished then set the value of the hidden field with you HASH
[HTML]
<script language="javascript">
window.onload = function sendHashToServer()
{
oMyHashField = document.getElementById('myHash');
oFrmHash = document.getElementById('oFrmHash');

oMyHashField.value = calHash();

oFrmHash.submit();

}

function calHash()
{
var hashString;
// some steps
return hashString;
}
</script>
<form id="frmHash" action="somewhere.aspx">
<input name="myHash" id="myHash" value="" />
</form>
[/HTML]

2-you can use ajaxRequest with GET or POST method.

[HTML]
var ajaxRec = //you must create your request object based on your browser with XMLHttpRequest or activeXObject('Microsoft.XMLHttp')

//eg. hash = SSKDEWAASKDE232DSFD
ajaxRec.open('GET','somewhere.aspx?myHash=SSKDEWAA SKDE232DSFD',true);
ajaxRec.send(null);
[/HTML]
3-you can use iframes too.

regards.
MH
Mar 4 '07 #3
Hey mohsenhosseini

Thnx for the reply. But what i want to know is dat like u have stated in the code an example called "calHash function" which calculates the hash value. In dat u specified "//some steps" which calculate the hash value. Now in .NET we have inbuilt functions & class libraries for calulating hash like MD5 and many more. So can i call these ready-made classes in this "calHash" function ?? What i m doubtful about is that, given the script is running on client side,will these classes be available always on client?

Note : .NET framework ( like JVM ) is installed on all the clients & not the SDK.
Mar 5 '07 #4
acoder
16,027 Expert Mod 8TB
Hey mohsenhosseini

Thnx for the reply. But what i want to know is dat like u have stated in the code an example called "calHash function" which calculates the hash value. In dat u specified "//some steps" which calculate the hash value. Now in .NET we have inbuilt functions & class libraries for calulating hash like MD5 and many more. So can i call these ready-made classes in this "calHash" function ?? What i m doubtful about is that, given the script is running on client side,will these classes be available always on client?

Note : .NET framework ( like JVM ) is installed on all the clients & not the SDK.
Well, if you really want those functions, you can use those functions from the server-side by making an XMLHttpRequest (i.e. Ajax). Create a page that just returns the hash value and use this in your script.
Mar 5 '07 #5
Hey mohsenhosseini

Thnx for the reply. But what i want to know is dat like u have stated in the code an example called "calHash function" which calculates the hash value. In dat u specified "//some steps" which calculate the hash value. Now in .NET we have inbuilt functions & class libraries for calulating hash like MD5 and many more. So can i call these ready-made classes in this "calHash" function ?? What i m doubtful about is that, given the script is running on client side,will these classes be available always on client?

Note : .NET framework ( like JVM ) is installed on all the clients & not the SDK.
hi
call me Mohsen.
check this link.
http://www.thescripts.com/forum/thread610641.html

in this link i describe ajax way to download somethings.
maybe it will usefull for you too.
Mar 7 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jeremy McPeak | last post by:
Howdy. First of all, awesome job on .NET 2.0! Now to my question: I love Master Pages and the Page.ClientScript; however, I am having trouble getting the two to play together. I can build a...
7
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
3
by: Stan SR | last post by:
Hi, I need to place some javascript code at the end of my aspx page. How can I do that using the ClientScript.RegisterClientScriptBlock ? Thanks Stan
2
by: verci | last post by:
Hi guys, I'm using asp.net 2.0, can anybody send me some complete examples on using ClientScript.RegisterClientScriptInclude and ClientScript.RegisterClientScriptSource, for registering an...
0
by: Vistaar | last post by:
Hi Guys, I m an engineering student working on web development project(in asp.net) and i am stuck up with the client side script. Precisly i want to run a complex function(which calculate the Hash...
1
by: HockeyFan | last post by:
My function to get an alert box on the page isn't working. Instead it puts in the bottom section of the page: <script type="text/javascript"> <!-- This is a test// --> </script> The...
9
by: Dariusz Tomoń | last post by:
Hello, I'd like to include JS from C# code (ASP.NET 2.0). I'm trying not directly from i.e. default.aspx.cs code but from a class belonging to DLL, which is referred in my project. The code...
0
by: HockeyFan | last post by:
I've done this many times with average pages, but in a case I have now, I have a master page with some controls on it. Under certain conditions when the user selects certain options, I want to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.