473,287 Members | 2,682 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,287 software developers and data experts.

Send Value From Client-Side Script To Server

I have some client-side JavaScript that, among other things, calculates the
value of a variable (myVar). On the server I have a stored procedure that
needs to somehow receive as an input parameter the value of myVar. I need to
know how to get the value of myVar from the script up to the server.
Specifically, I'd like to have the following happen when the user clicks a
button in the browser:
1. The client-side script executes (and determines the value of myVar).
2. A postback is initiated - at which time the value of myVar is sent to an
aspx.cs function which ultimately...
3. executes a stored procedure (which receives the value of myVar as an
input parameter).

This is a very important piece of a larger project... any help would be
greatly appreciated - including any JavaScript syntax, as I'm a but rusty on
my JavaScript skills.

Thanks!

-GH
Nov 18 '05 #1
6 3307
Please note: I only need help with getting the value from the client-side
script to the server-side aspx.cs function. I can take it from there -
Thanks!
"Guadala Harry" <Ch*********@gh.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have some client-side JavaScript that, among other things, calculates the value of a variable (myVar). On the server I have a stored procedure that
needs to somehow receive as an input parameter the value of myVar. I need to know how to get the value of myVar from the script up to the server.
Specifically, I'd like to have the following happen when the user clicks a
button in the browser:
1. The client-side script executes (and determines the value of myVar).
2. A postback is initiated - at which time the value of myVar is sent to an aspx.cs function which ultimately...
3. executes a stored procedure (which receives the value of myVar as an
input parameter).

This is a very important piece of a larger project... any help would be
greatly appreciated - including any JavaScript syntax, as I'm a but rusty on my JavaScript skills.

Thanks!

-GH

Nov 18 '05 #2
You can make the button to be a client-side button that invokes the script,
then store the value to a hidden control with "runat=server" and finally
call a server-side button to post the data to server(possibly with a
document.FindElementbyId().click()).
If there should be only one button on the form, you may want to try an
ImageButton with "white" image.

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:%2****************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
I have some client-side JavaScript that, among other things, calculates the value of a variable (myVar). On the server I have a stored procedure that
needs to somehow receive as an input parameter the value of myVar. I need to know how to get the value of myVar from the script up to the server.
Specifically, I'd like to have the following happen when the user clicks a
button in the browser:
1. The client-side script executes (and determines the value of myVar).
2. A postback is initiated - at which time the value of myVar is sent to an aspx.cs function which ultimately...
3. executes a stored procedure (which receives the value of myVar as an
input parameter).

This is a very important piece of a larger project... any help would be
greatly appreciated - including any JavaScript syntax, as I'm a but rusty on my JavaScript skills.

Thanks!

-GH

Nov 18 '05 #3
How do I do the following part of what you recommend - do you have specific
JavaScript Syntax?
<<...and finally call a server-side button to post the data to server...>

Does anyone have an easier way to accomplish what I'm after?

Thanks for your input so far - GH.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
You can make the button to be a client-side button that invokes the script, then store the value to a hidden control with "runat=server" and finally
call a server-side button to post the data to server(possibly with a
document.FindElementbyId().click()).
If there should be only one button on the form, you may want to try an
ImageButton with "white" image.

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:%2****************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
I have some client-side JavaScript that, among other things, calculates the
value of a variable (myVar). On the server I have a stored procedure that needs to somehow receive as an input parameter the value of myVar. I need to
know how to get the value of myVar from the script up to the server.
Specifically, I'd like to have the following happen when the user clicks
a button in the browser:
1. The client-side script executes (and determines the value of myVar).
2. A postback is initiated - at which time the value of myVar is sent to

an
aspx.cs function which ultimately...
3. executes a stored procedure (which receives the value of myVar as an
input parameter).

This is a very important piece of a larger project... any help would be
greatly appreciated - including any JavaScript syntax, as I'm a but

rusty on
my JavaScript skills.

Thanks!

-GH


Nov 18 '05 #4
Use the statement:
document.FindElementbyId("bt_submit").click();
where bt_Submit is a button with "runat=server" & " id='bt_submit'
"properties set.

I've already suggested that in my last post.

You'll have to follow this kind of approach as there's no easier method to
pass value to server-side using form-submittion(get/post)

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:eg**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
How do I do the following part of what you recommend - do you have specific JavaScript Syntax?
<<...and finally call a server-side button to post the data to server...>

Does anyone have an easier way to accomplish what I'm after?

Thanks for your input so far - GH.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
You can make the button to be a client-side button that invokes the script,
then store the value to a hidden control with "runat=server" and finally
call a server-side button to post the data to server(possibly with a
document.FindElementbyId().click()).
If there should be only one button on the form, you may want to try an
ImageButton with "white" image.

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:%2****************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
I have some client-side JavaScript that, among other things, calculates
the
value of a variable (myVar). On the server I have a stored procedure that needs to somehow receive as an input parameter the value of myVar. I need
to
know how to get the value of myVar from the script up to the server.
Specifically, I'd like to have the following happen when the user
clicks a button in the browser:
1. The client-side script executes (and determines the value of

myVar). 2. A postback is initiated - at which time the value of myVar is sent to an
aspx.cs function which ultimately...
3. executes a stored procedure (which receives the value of myVar as

an input parameter).

This is a very important piece of a larger project... any help would be greatly appreciated - including any JavaScript syntax, as I'm a but

rusty
on
my JavaScript skills.

Thanks!

-GH



Nov 18 '05 #5
Thank you very much.

I'll give it a whirl.

-GH
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:u7***************@tk2msftngp13.phx.gbl...
Use the statement:
document.FindElementbyId("bt_submit").click();
where bt_Submit is a button with "runat=server" & " id='bt_submit'
"properties set.

I've already suggested that in my last post.

You'll have to follow this kind of approach as there's no easier method to
pass value to server-side using form-submittion(get/post)

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:eg**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
How do I do the following part of what you recommend - do you have specific
JavaScript Syntax?
<<...and finally call a server-side button to post the data to server...>

Does anyone have an easier way to accomplish what I'm after?

Thanks for your input so far - GH.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
You can make the button to be a client-side button that invokes the

script,
then store the value to a hidden control with "runat=server" and finally call a server-side button to post the data to server(possibly with a
document.FindElementbyId().click()).
If there should be only one button on the form, you may want to try an
ImageButton with "white" image.

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:%2****************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
> I have some client-side JavaScript that, among other things,

calculates the
> value of a variable (myVar). On the server I have a stored procedure

that
> needs to somehow receive as an input parameter the value of myVar. I

need
to
> know how to get the value of myVar from the script up to the server.
> Specifically, I'd like to have the following happen when the user clicks
a
> button in the browser:
> 1. The client-side script executes (and determines the value of

myVar). > 2. A postback is initiated - at which time the value of myVar is
sent to an
> aspx.cs function which ultimately...
> 3. executes a stored procedure (which receives the value of myVar as an > input parameter).
>
> This is a very important piece of a larger project... any help would be > greatly appreciated - including any JavaScript syntax, as I'm a but

rusty
on
> my JavaScript skills.
>
> Thanks!
>
> -GH
>
>



Nov 18 '05 #6
While it got me going in the right direction, I had no luck with
document.FindElementbyId("bt_submit").click(); But for those of you who
may be interested in the outcome of this thread, a variation of the
recommendation is what works:

This is the hyperlink that, when clicked, executes the client-side
JavaScript function:
<a id="HyperLink1" href="javascript:TestPostBackFromJavaScript()" >Test Save
From JavaScript</a>

Here is the JavaScript Function
function TestPostBackFromJavaScript() {
document.all("btnSaveChanges").click();
}

That JavaScript function effectively "clicks" the following ASP.NET button:
<asp:Button id="btnSaveChanges" EnableViewState="true"
CommandName="SaveChanges" Visible="true" Width="115" runat="server"
Text="Save Changes"></asp:Button>

Thanks to Lau Lei Cheong for pointing me in the right direction.

GH
"Guadala Harry" <Ch*********@gh.com> wrote in message
news:e0**************@TK2MSFTNGP12.phx.gbl...
Thank you very much.

I'll give it a whirl.

-GH
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:u7***************@tk2msftngp13.phx.gbl...
Use the statement:
document.FindElementbyId("bt_submit").click();
where bt_Submit is a button with "runat=server" & " id='bt_submit'
"properties set.

I've already suggested that in my last post.

You'll have to follow this kind of approach as there's no easier method to
pass value to server-side using form-submittion(get/post)

"Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
news:eg**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
How do I do the following part of what you recommend - do you have

specific
JavaScript Syntax?
<<...and finally call a server-side button to post the data to server...>
Does anyone have an easier way to accomplish what I'm after?

Thanks for your input so far - GH.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
> You can make the button to be a client-side button that invokes the
script,
> then store the value to a hidden control with "runat=server" and finally > call a server-side button to post the data to server(possibly with a
> document.FindElementbyId().click()).
> If there should be only one button on the form, you may want to try an > ImageButton with "white" image.
>
> "Guadala Harry" <Ch*********@gh.com> ¦b¶l¥ó
> news:%2****************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
> > I have some client-side JavaScript that, among other things,

calculates
> the
> > value of a variable (myVar). On the server I have a stored procedure that
> > needs to somehow receive as an input parameter the value of myVar. I need
> to
> > know how to get the value of myVar from the script up to the server. > > Specifically, I'd like to have the following happen when the user

clicks
a
> > button in the browser:
> > 1. The client-side script executes (and determines the value of

myVar).
> > 2. A postback is initiated - at which time the value of myVar is

sent
to
> an
> > aspx.cs function which ultimately...
> > 3. executes a stored procedure (which receives the value of myVar as an
> > input parameter).
> >
> > This is a very important piece of a larger project... any help
would be
> > greatly appreciated - including any JavaScript syntax, as I'm a

but rusty
> on
> > my JavaScript skills.
> >
> > Thanks!
> >
> > -GH
> >
> >
>
>



Nov 18 '05 #7

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

Similar topics

3
by: Alberto Vera | last post by:
Hello: Could you tell me How I can send an email using WIN2000? What do I need? Thanks
0
by: Alexiel | last post by:
Hi, i have a problem, I have a Java Client and i call my webservice on ..NET. This run perfectly just except when i send parameters don't work fine. I send my code : This is my java...
3
by: rob | last post by:
I have an win form app from which I want to be able to send bug reports. My first approach was something like: SmtpClient client = new SmtpClient( ????? ); MailAddress from = new...
0
by: Jay | last post by:
The code below is a recommended way to send email with c# from my aspx page: MailMessage mail = new MailMessage(); mail.From = new MailAddress("development@ziptax.com"); mail.To.Add(new...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
0
by: Buddy Home | last post by:
There is two examples of code. Example 1. Send and Receive within the same process. Put this code in a console app called SendAndReceive and run the code. using System; using...
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
2
by: Ethan Strauss | last post by:
Hi, I have a web service which is doing a lot of processing and taking 4-5 minutes to do so. The processing is split into several discrete steps and I would like for the service to be able to tell...
9
by: Ethan Strauss | last post by:
Hi, I have a web service which is doing a lot of processing and taking 4-5 minutes to do so. The processing is split into several discrete steps and I would like for the service to be able to tell...
16
by: =?Utf-8?B?Q2hlZg==?= | last post by:
I can use outlook2003 to send email,but I cann't use this code below to send email. Please help me to test this code and instruct me how to solve this problem in detail. software...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.