Getting my client-side variable over to server-side

Ok so I have looked at a few posts on this subject and I can't quite figure out how to apply the idea to what I am doing here.

I am using javascript to take amounts from 7 different textboxes and add them up on the fly, dropping the total in the 8th textbox.

After they fill in that information they click button (postback) to continue throughout the form... what I need is for the "textboxTotalAmt" to move from client-side to server-side.  So I can access that total amount later in the form.

Here is the Javascript piece...

<script type="text/javascript"><!--
function ValidNumber(e)

 if(isNaN(e.value))
 {
  e.value = "0.00";
 }
 else
 {
  e.value = ""+Number(e.value).toFixed(2);
 }
return e.value;
}
function CalTotal1()
{
 var varTotalGeneral
 var vartotal1 = ValidNumber(window.document.getElementById('textbox01'));
 var vartotal2 = ValidNumber(window.document.getElementById('textbox02'));
 var vartotal3 = ValidNumber(window.document.getElementById('textbox03'));
 var vartotal4 = ValidNumber(window.document.getElementById('textbox04'));
 var vartotal5 = ValidNumber(window.document.getElementById('textbox05'));
 var vartotal6 = ValidNumber(window.document.getElementById('textbox06'));
 var vartotal7 = ValidNumber(window.document.getElementById('textbox07'));
 
 varTotalGeneral= parseFloat(vartotal1) + parseFloat(vartotal2) + parseFloat(vartotal3) + parseFloat(vartotal4) + parseFloat(vartotal5) + parseFloat(vartotal6) + parseFloat(vartotal7);
 window.document.getElementById('textboxTotalAmt').value = ""+varTotalGeneral.toFixed(2);
 
 }

window.onload=function(){
 CalTotal1();
}
 
//--></script>

Any help would be appreciated

0
toneez
7/16/2008 3:15:09 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies
1003 Views

Similar Articles

[PageSpeed] 23

 

try this

www.tek-tips.com/faqs.cfm?fid=603

0
itsumapathyk
7/16/2008 3:22:45 PM

What do you try to do?

if you want to implement server side function+client side function in one button click. You need to use ClientScriptBlock or more popular technique, AJAX 

0
webberman
7/16/2008 3:36:10 PM

Maybe I've misunderstood the question, but can't you just access the textboxTotalAmt's text in the handler of the button?  Just store it in viewstate if you want to keep the value for later on like ViewState("textboxTotalAmt") = textboxTotalAmt.Text.


We're all in this together.
0
conankingofcool
7/16/2008 3:52:28 PM

 Any reason why you can't use server side function to calculate the total and put it to the 8th textbox? This would've been much easier appoarch.

0
photoshoper
7/16/2008 3:59:34 PM

Well I ended up figuring out a way to get what I needed without having to pass the javascript variable.

Basically the javascript is just being used for 'pretty' purposes now and I just created server-side code to add up the fields for the final total.  As I see somebody just suggested as well.

Thanks

0
toneez
7/16/2008 4:15:33 PM

Create one hidden server variable and assign the total value in it.

You will able to access the the hidden field in server side.

input type="hidden" id="txtTotal" runat="server"
 


Please mark it as answer if it resolves the issue.

visit: http://technicalsol.blogspot.com
0
sumitd
7/16/2008 4:35:44 PM
Reply:

Similar Artilces:

How to Access/Pass Server Side Array Variable at Another Web Form's Client Side
Hi All,I struck up with some intrested senario at my application development...hope some body will guide me or sends me some code snippets....Thanks in advance.Senario is like this.....in A.aspx (using C# .net 2.0 as code behind) I am going to have a array variable basically it is an TWO Dimensional array after populating the values in array I need to redirect/ reload another web form B.aspx, here i need to access the array in B.aspx client side JavaScript.How can I do this...Thanks AgainRaju Dont do a redirect but use server.transfer. That way the previous page will still hold its value, ...

Getting hidden variable value from server side in client side
hi,        I am struck in problem. I have a hidden field in my form and i am setting some value in that.         Now i wnt to use this value from client side but i m not able to retrieve it. All i am getting there is an object.         I feel the hidden field is not able to hold that value.         <input type="hidden" id="hdnVar" runat="server" />         in code behind      ...

Passing variable between client side and server side
For example,how do I pass the return value of the confirm("whatever") to the server side? Or the opposite way.  I want to use a cookie to do is. Can some one give me hint.  Much appreciate your help.   Chen  Please "Mark as an Answer" if you think my post had helped you!Thanks. you can use ajax,javascript and cookies also.  Got what you needed. Please mark as answer. In the aspx file: <input type="hidden" id="confirmAnswer" name="confirmAnswer" runat="server"> That adds this to the...

Server side Variable in client side script
Hello, I want to access the variable defined in the server side script from the client side. Can anyone help out with an example ??? TIA, Rakesh Babaria I think what you do is write is as a java script variable, so something like this: <!--SCRIPT var ls_serverVar ls_serverVar = "whatever"; document.writeln("<SCRIPT language=JavaScript>"); document.writeln("var xyz = " + ls_serverVar); document.writeln("</SCRIPT>"); --> Then in your client script, you'll be able to get XYZ. ...

server side variables in client side javascript
I want to use an ASP.net variable in client side javascript.In regular asp I used hidden fields.what is the best way to do this in ASP.NET ?thx,Intersee my blog at www.Interdevelopments.com and check the future of open mobile widget solutions at www.glowe.org By and large, I personally still use Hidden fields to store information, that either my Javascript function or my code-behind use.  I barely use the RegisterScriptBlock method(s) and that is only for situations where I want to be really dynamic with the client side functionality.  95% of the time, I can still use a...

how to transfer client-side variable to server-side
hi all, i need just a small hint on how to go on... i am adding attributes to a rows in a gridview when data is bound e.Row.Attributes.Add("onClick", "MySelectedRow.text = '" + e.Row.DataItemIndex.ToString() + "';location.href='admin_contact.aspx'") this allows me to store the selected row in a hidden field (MySelectedRow). after the page is being resubmitted it resets the value of the hidden field to null. i need to have the value on the server-side. i prefer not to do the querystring unless you know how to clear the querystring i...

differences between server side asynchronous Web methods and client side asynchronous Web methods
Hi,   can anyone expalin what are the differences between server side asynchronous Web methods  and client side asynchronous Web methods in ASP.Net 2.0 ?   any best articles on serverside asynchronous Web methods  ?   Thanks,  hi, check this url, Server-Side Asynchronous Methods for ASP.NET, http://www.codeproject.com/KB/cpp/asyncws.aspx   Calling the Server-Side method asynchronously from Client Script, http://www.c-sharpcorner.com/UploadFile/dipenlama22/Callbacks07182006093320AM/Callbacks.aspx...

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

form double validation- server side and client side
Hi! I would like to make a server side validation after calling a js function that makes the client-side validation. I do not understand couple of things: 1. Do i need a server side button or  a simple HTML submit button in order to call both of the tests? 2. How do i call a server side function which is written in csharp  after i finish my JS validation (the submit  button is calling the JS function for validation first.)- is it possible to call it directly from a js function? 3. I know that my toolbox on asp.net  contains validation controls who probably are b...

Using server side global variable on client side
I have a function which retrieves certain values from ldap server. I have written server side code to get the data. Now I want to show the values on a html form. I tried to create client side variable within server side script and use it but when I start it says Undefined variable as_firstname, if I add <SCRIPT> as_firstname="test" </SCRIPT> after <!--SCRIPT> and --> tag before </HEAD> it displays the value. Can someone say what is wrong in this? My Code is <HTML> <HEAD> <!--SCRIPT import JavaWrapper.ssc; fun...

Loading client side variables from server side code
Just curious whether anyone has seen a better way to implement the following. It doesn't seem like the best way! What I'm doing is passing in an array of values to the client via server side code. The reason for this is because I'd like the server to do most of the crunch work and then pass the final results to the client. I use the 'onload' event of an image. code behind: imgLoader.Attributes.Add("onload", "Init('Tag1;Tag2;Tag3')") client-side. The page also contains an image called 'imgLoader'. var Entities = new Array(); function Init(s) ...

Accessing server-side variables from client-side events
This is a multi-part message in MIME format. ------=_NextPart_000_00E8_01C04D70.7EAC7080 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable In a client-side itemchanged function, how can I set a server-side = variable?? I simply need to execute the following: psSession.SetValue("userID", user_id); I'm sure there's a way to trigger server-side script and pass in = variables. Any suggestions?? Thanks. ------=_NextPart_000_00E8_01C04D70.7EAC7080 Content-Type: text/html; charset="iso-8859-1" ...

get server side datetime but run at client side
How do I get the server side datetime eg( 4 Aug 2006  6:12 : 01(seconds) AM  ) which the time is something similiar to ticking clock, once it get the server side datetime, it will pass to the javascript. From javascript it will increment the second by one, it is just similiar to ticking clock, after 10 seconds it will synchronize to the server datetime which means it get the latest server side datetime.   Is there any guide ? thanks in advance!!!kiwi_cyh Hi, It seems you want to synchronize the time in client side display with the server. You can use asynchronous clie...

Accessing Client side variable from server side code?
Hi,  I am trying to use vbscript to run a process on the client machine. Once that process finishes I want to use the resulting value in my server side code behind file. Does anyone know a way to do this? I know that I can set server side session objects to a client variable by doing something like this: <script language="vbscript" type="text/vbscript">  strSubject = <%=Session.Item("Subject") %> </script>  but I have no idea how to do that in reverse. Thanks!    Filed under: too much coffee.  LOL! ...

Web resources about - Getting my client-side variable over to server-side - asp.net.web-forms

Client-side - Wikipedia, the free encyclopedia
Client-side refers to operations that are performed by the client in a client–server relationship in a computer network . Typically, a client ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 1/14/2016 8:14:25 PM