473,388 Members | 1,606 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,388 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 3309
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
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...

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.