By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Send Value From Client-Side Script To Server

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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> 秎ン
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 #3

P: n/a
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> 秎ン
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 #4

P: n/a
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> 秎ン
news:eg**************@tk2msftngp13.phx.gbl い级糶...
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> 秎ン
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 #5

P: n/a
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> 秎ン
news:eg**************@tk2msftngp13.phx.gbl い级糶...
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> 秎ン
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 #6

P: n/a
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> 秎ン
news:eg**************@tk2msftngp13.phx.gbl い级糶...
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> 秎ン
> 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 #7

This discussion thread is closed

Replies have been disabled for this discussion.