Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2004, 02:05 AM
Authorized User
 
Join Date: Feb 2004
Location: Delhi, Delhi, India.
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 ?
__________________
-.. -..
  #2 (permalink)  
Old March 9th, 2004, 03:41 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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.
  #3 (permalink)  
Old March 9th, 2004, 04:21 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
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.
  #4 (permalink)  
Old March 9th, 2004, 09:46 PM
Authorized User
 
Join Date: Feb 2004
Location: Delhi, Delhi, India.
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.
  #5 (permalink)  
Old March 9th, 2004, 09:49 PM
Authorized User
 
Join Date: Feb 2004
Location: Delhi, Delhi, India.
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.



  #6 (permalink)  
Old March 10th, 2004, 03:52 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:18 AM.


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