Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2004, 02:05 AM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default Evaluating Textbox in Realtime without postback

Hi, all

My page consists of a row of textboxes And a final textbox named Total

    tb1 tb2 tb3 tb4 ........ Total

Total has the sum of the values in tb1 , tb2,...

I want to dynamically calculate the value of Total each time one of the
textbox values are changed.

Presently I am handling the OnTextChanged event and it works fine but only
when the pagepostbacks

I don't want the page to postback i.e. Autopostback ="False" and still
evaluate Total Dynamically.

How can it be done ?
__________________
-.. -..
 
Old March 9th, 2004, 03:41 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

For this to work, you'll need to emit some JavaScript to the client. Add an onblur handler for each text box, that fires a client side JavaScript function. This function retrieves the values from the text boxes and then updates the Total text box.

Take a look at Page.RegisterClientScriptBlock and at the Attributes collection of a Web Control. The first allows you to send the actual function, the second allows you to add an onblur handler to the text boxes.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 9th, 2004, 04:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

if u dont want to not postback that means u dont want to do it by ServerScripting so u have to use JavaScript as a ClientScript lang.

Always:),
Hovik Melkomian.
 
Old March 9th, 2004, 09:46 PM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default

Quote:
quote:Originally posted by Imar
 Hi there,

For this to work, you'll need to emit some JavaScript to the client. Add an onblur handler for each text box, that fires a client side JavaScript function. This function retrieves the values from the text boxes and then updates the Total text box.

Take a look at Page.RegisterClientScriptBlock and at the Attributes collection of a Web Control. The first allows you to send the actual function, the second allows you to add an onblur handler to the text boxes.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 9th, 2004, 09:49 PM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default


I am creating the textboxes Dynamically usiing the placeholder control. Can I still use the OnBlur property.

Secondly if I have <%@ Page Language ="VB" > at the start of my code , then how and where can I use JavaScript.



 
Old March 10th, 2004, 03:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Of course you can. After you created your text box dynamically, simply use its Attributes collection. The control will be sent to the client, where the JavaScript will fire.

That will also answer your second question: The VB language is used to construct the page at the server; the JavaScript is sent to the client and will fire right there, in the browser.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
textbox viewstate missing on postback JoshuaZ Classic ASP Basics 6 August 27th, 2008 03:45 PM
Evaluating IF something is in a list fizzerchris SQL Server 2005 2 October 17th, 2007 05:37 PM
realtime communication turdy VB.NET 0 February 28th, 2006 10:08 AM
Evaluating body content of a custom tag Tag Librarian Pro JSP 0 May 13th, 2005 02:40 PM
Want to get my realtime clock to chime The Wizard Pro JSP 0 February 11th, 2004 08:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.