How to change the value of textbox without posting page back to the server

Hello everyone,

I have a simple form with 3 textboxes namely txtNumber1, txtNumber2, txtTotal.

The txtTotal will display the sum of txtNumber1 and txtNumber2. I'd like when the user enter a number either in txtNumber1 or txtNumber2 the txtTotal will automatically update its value without posting page back to the server. Do I need to utilize Ajax to accomplish it?

Thanks for reading.  

9/1/2008 8:20:53 AM 93655 articles. 6 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 0

There are couple of options you can use:

1] Use Java Script to Populate your txtTotal on change of text in txtNumber1  / txtNumber2

2] You can use AJAX, by putting your controls in UpdatePanel. Have a button Calculate (outside Update Panel), which will calculate and populate txtTotal from you.

Ho[pe this helps.



9/1/2008 8:40:31 AM

I think i will use the first approach. But could you please tell me more detail?I'm not sure how to use JavaScript in ASP.NET pages.

Thank you for your reply

9/1/2008 8:46:43 AM


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sum Example</title>
<script type="text/javascript">
function Sum()
	var txtNumber1 = document.getElementById('txtNumber1');
	var txtNumber2 = document.getElementById('txtNumber2');
	var txtTotal = document.getElementById('txtTotal');
	if (txtNumber1.value.length > 0 && txtNumber2.value.length > 0 && isNaN(txtNumber1.value) == false && isNaN(txtNumber2.value) == false)
		txtTotal.value = txtNumber1.value*1 + txtNumber2.value*1;
		txtTotal.value = '';
Number 1: <input type="text" id="txtNumber1" onBlur="Sum();" /><br>
Number 2: <input type="text" id="txtNumber2" onBlur="Sum();" /><br>
Total: <input type="text" id="txtTotal" />

 If you want to use asp:Textbox the from server side add attribute of Textbox.


In Page_Load



I hope this help you.

Please mark as Answer if it helps u. Thanks!

Parth Patel
Techsture Technologies
Software Developer
9/1/2008 8:55:16 AM

Thanks for your post. It worked as I expected

9/1/2008 9:37:41 AM

Similar Artilces:

Can you post a page back to the server without a form?
Can you post a page back to the server without a form from the HTML side? What are my options?  I am using Sharepoint with webparts that do not have a form in the code. I need to seperate a few things/functions based on some criteria that I can't get unless I submit the page back to the server.   any suggestions? Not sure if this is useful to help get me an answer But something like onclick="__doPostBack('CheckBox1','') but I all I want to do is post the entire page back....I dont care about checkboxes or txt boxes.  Just posting it back to s...

Change content pages of Master Page without Master Page posting back?
so Master + content pages seems like exactly what I want except that they are assembled on postbacks. I am trying to make a site where both Master and Content pages have updatepanels, and the site switches content pages (40+ content pages) without the master page refreshing. Master Pages are assembled on postbacks so I don't think simple master page will work without annoying postbacks. I tried an approach where load content pages inside an Iframe, but the content pages take too long to load becuase each content page loads its own scriptmanager. View/Multiview will probably work but dif...

How to preserve values in a web form when navigating to a different page and then going back to the original page using the back button ?
   I am working on a C#/ASP.NET web application. The web application basically consist of 3 web forms. Each form contains several controls such as an edit box, and some drop down list box controls. Basically I need to find out how to preserve the values in a web form when a person navigates to a different page. For example, suppose that in my web application I navigate from my first page (First.aspx) to my second page (Second.aspx). Now if I press the browsers back button, I want the application to retain the values for the controls that were in my first web form "first....

can i use a calendar picker control in my form without it posting back the page when i pick or change the date?
can i use a calendar picker control in my form without it posting back the page when i pick or change the date? First: Then Mike [MVP - ASP/ASP.NET]My site jolyon:can i use a calendar picker control in my form without it posting back the page when i pick or change the date?  Based on my understanding, you can try to use JavaScript to solve your problem.Also I write a demo for your reference only; Please look at the part of "bold";CalendarDemo.aspx: <%@ Pa...

Could PB .NET Web Form POST security Information to others web page??
This is a multi-part message in MIME format. ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi,=20 Have anyone came across the requesion to POST security informations from = PB .NET web form web page to other web site?? I have tried many datys, Could any kind man give me some suggessions?? thanks & Best regards Leon ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML P...

How to load pages only in the content area without posting the entire page back to the server?
HiCan anyone suggest a method by which I could possibly load only the content area as I don't want the menu and other images around the content area to be loaded again with the same content as the data in the content area only changes without any change in the surrounding area of the pages. Is there any method other than using controls to load the content area without a postback?Thanks Karthik MuthuswamyProgrammer AnalystChennai It looks like what you need is the UpdatePanel to do partial-page rendering. This part of the Microsoft AJAX extensions.   Check out this link: http://...

Multiple Page Web-forms, without passing earlier pages values to the next one?
I am using RH9, postgreSQL and perl5. Is it possible to get users to submit multiple page web-forms but not to pass values from one form to the next? I would like to store each page to the database server as it is submitted. Also, to build in the process to resume the web-form submission at a later time e.g say there are twent pages to submit and the user stops feeding the forms at the tenth form. I would like to email the user a reminder so he can log back in and start from the eleventh form. Can anyone tell me if this sort of thing is implemented anywhere, so I can study it. Or, can anyone p...

How to change the TEXTBOX text without doing a post back?
How to change the TEXTBOX text without doing a post back? The textbox is <asp:textbox> , i mean web form based textbox not the html one. I wanna use this method to insert html tags cuz i didn't find free richtextbox or something with the same function. thanksASP.NET Hosting (HostingFest) if your not posting back, then your at the client so you need to use javascript. the <asp:textbox> renders as a standard input controlMike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: Edited by SomeNewK...

Changing the value of a textbox without submitting the form
Hi there, I have 3 buttons on a form. the first is for submitt the form and the other 2 is for changing the values of a textbox without submitting the form. When I click on this two buttons the form is submitted and the value of the textboxs are changed. Can I change the values of the textbox without submitting the form. Thanks Use html buttons and javascript. <input type="button" onclick="javascriptThatChangesTextBoxes()" value="Display alert box"> Jigar Desai-----------------------Do not forget to "Mark as Answer" on the ...

where is the value saved of the form controls(such as textbox) in post backs?
hello! I have some puzzle in view state.I have just read an article in Msdn about view state.,It says, there are many stages in the life cycle of the page,and the Stage 2 is Load View State,the Stage 3  is Load Postback Data.In Stage 2 ,it says : During this stage, the view state data that had been saved from the previous page visit is loaded and recursively populated into the control hierarchy of the Page. And the Stage 3 is Load Postback data of the form controls, My first question is: what is the difference of the view stat...

How to change the value of a TextBox inside a Web Form in Insert mode?
Hi, If the textbox txtDate is outside a Web Form, we can change the values as follow: txtName.Text = "James"; If the item is inside a Web Form in Insert mode, how can I change the TextBox value by using .net script or JavaScript at run-time?  Thanks, James Hi James,If I understand your question, you want to be able to change the value using JavaScript within the browser, not the code-behind.  You would do that with something like this:<script language="javascript" type="text/javascript">document.getElementById(<%=txtName.ClientID.ToStr...

Posting values from one web form to another aspx page
How would I post the values from a form in my application to another form in someone elses application using I understand it differs from asp 3.0 as pages in 1.1 post to themselves and a redirect doesn't post the values to the other form. Any help would be appreciated. If its on the same server try Context.Items["name"] = myText; Server.Transfer("page.aspx"); The application is on a different server. Would/Could/Should I have my aspx page redirect to a asp page which would then collect and transmit the values to the "other" app...

re-posting a page back to the server after a pop up form is closed
Is there a way to post-back a calling web form after a pop up form is closed to re-populate data?Jeff Wasilauski, MCAD .NET, MCPC# WEB DEVELOPMENT-SQL SERVER DBA"If I have answered your question please mark as answer" window.opener.location.reload(); Ok.  But how do I trigger this event?Jeff Wasilauski, MCAD .NET, MCPC# WEB DEVELOPMENT-SQL SERVER DBA"If I have answered your question please mark as answer" Just place that line of javascript right before your call to window.close(). Thanks Stiletto That worked.  JeffJeff Wasilauski, MCAD .NET, MCPC# WE...

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: might ...

Web resources about - How to change the value of textbox without posting page back to the server -

Aqua (user interface) - Wikipedia, the free encyclopedia
Aqua is the GUI and primary visual theme of Apple Inc. 's OS X operating system . It is based around the theme of water, as its name suggests, ...

Wikipedia:Sockpuppet investigations - Wikipedia, the free encyclopedia
WP:RFCU redirects here. You may be looking for Wikipedia:Requests for comment/User conduct ( WP:RFC/U ), CheckUser policy ( Wikipedia:CheckUser ...

Help - is a social service . Users can post short(140 character) status messages which are broadcast totheir friends and colleagues on the ...

City of Whitehorse, YT : Contact
Employment - Bylaws - Document Library - FAQ - Contact Us Search Query Textbox Home Home About Whitehorse Notify Me Contact Us Employee Links ... Help
Help for uploading pictures Noun explanation Group pictures: a basic unit which stands for a piece of news photo in system; include: information ...

Metamorphose: All-In-One File/Folder Renamer For Windows, Mac & Linux
Previously, we’ve reviewed many batch file-renaming applications like ReNamer (read review), NameChanger (read review), File Grinder (read review) ...

How to build a Twitter extension for Chrome
Ars takes a close look at the Chrome Web browser's new extension system. In …

ASUSTeK Computer Inc. -Support- RSS
... RSS Service, please follow the instructions below. STEP 1. Select the product to subscribe. STEP 2. The RSS link will be shown on the Textbox ...

authonomy writers and readers - Daniel Escurel Occeno's profile - authonomy writing community
... of the Point Guard”. It is entered in writing contest.In the TEXTNOVEL website simply type in “Lee Chon” in the textbox search ...

Baseball Prospectus
Forgot Your Password? Enter your username in the textbox below. Username: If you don't remember your username, please contact Customer Service ...

Resources last updated: 12/26/2015 12:18:20 PM