TextBox Control

S

Shelly

In looking at the asp.net TextBox, I noticed that there is a property called
"OnTextChanged". I tried to use this control to call a subroutine called
"GetCompanyProperties". The field is the account number. When a user
enters an account number and then tabs or points to another field, I want
the subroutine called so that it can access the database and get the data
fill out six other fields. Nothing happens when I enter the account number
and tab to another text box.

In researching this, I found that I had to set the AutoPostBack property to
true. Still nothing happened. Further reading said that "The ability of a
TextBox control to post automatically to the server when it's text is
changed requires that the browser support ECMAScript and that scripting is
enabled on the user's browser."

I am running Internet Explorer 7. How do I determine if (a) ECMAScript is
supported and (b) if scripting is enabled?
 
S

Shelly

Eliyahu Goldin said:
It is in your browser's security settings: Tools-Internet
Options-Security.

Before I posted the last time, I looked there. I couldn't find it. That
was why I posted. I also looked in the Advanced tab. Maybe it is there
under another name. In any event, for the intranet (local machine), just
about everything is enabled.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Shelly said:
In looking at the asp.net TextBox, I noticed that there is a property
called "OnTextChanged". I tried to use this control to call a subroutine
called "GetCompanyProperties". The field is the account number. When a
user enters an account number and then tabs or points to another field, I
want the subroutine called so that it can access the database and get the
data fill out six other fields. Nothing happens when I enter the account
number and tab to another text box.

In researching this, I found that I had to set the AutoPostBack property
to true. Still nothing happened. Further reading said that "The ability
of a TextBox control to post automatically to the server when it's text
is changed requires that the browser support ECMAScript and that
scripting is enabled on the user's browser."

I am running Internet Explorer 7. How do I determine if (a) ECMAScript
is supported and (b) if scripting is enabled?
 
E

ed

Hi Shelly,

ECMA script just means "JavaScript". IE has supported it since way
back, something like version 2 or 3. It's still there in 7 and not
going anywhere :)

To find out if script is enabled: It nearly always is. I'm not even
sure if there's an IE setting for disabling script any more -- in my
IE6 the security settings are all about what script can do, not if
it's enabled or not.

So your answer probably lies elsewhere.

In general, looking up values in the middle of a web form can get
complicated. It's doable but hard to write and harder still to
maintain (an opinion of course, not a fact). You might want to
consider changing the design so you can avoid it too. I think you'll
find that the easiest approach is:

Page A. Prompt for the account number, and if it's valid go to page B.
Page B. Display account properties; show a "Select another account"
button that will go back to page A.

That's also more common; more or less how Amazon, eBay, Google, etc
implement lookups.

Hope this helps,
- Ed
 
E

ed

Just saw your second post that you're doing an Intranet app. Never
mind - you can get away with the auto postback more easily there,
though I still think it's a little harder to code.

I doubt it's a scripting enabled/disabled problem. Try this: in design
mode, bring up the properties window for your textbox and check the
events. Is the TextChanged event mapped? If not, enter a method name
(anything will do). VS.NET will create a new event handler method
using the name you entered. You can call your GetCompanyProperties
method from there.

Hope I'm barking up the right tree here. Good luck.

- Ed
 
S

Shelly

Thanks Ed. I know I can change the design. What I can do is not display
the information and only have the account number to enter. The rest of the
fields are only there for cosmetic purposes and are, in fact, readonly. In
the real world, that is what I would do. However, this is for my learning
purposes only and I wanted to see if there was a way. When I wrote this
application for the customer it was on a Linux system and was in php. I
used your A, B approach there. I am rewriting it on my local machine in
asp.net/vb.net purely as a learning tool. I have found in the past that the
hardest part of learning something new is to come up with meaningful
exercises. This one has been great so far.

P.S. Thanks to all of you that have helped me in my learning (asn
especially Mark).

Shelly
 
S

Shelly

Just saw your second post that you're doing an Intranet app. Never
mind - you can get away with the auto postback more easily there,
though I still think it's a little harder to code.

I doubt it's a scripting enabled/disabled problem. Try this: in design
mode, bring up the properties window for your textbox and check the
events. Is the TextChanged event mapped? If not, enter a method name
(anything will do). VS.NET will create a new event handler method
using the name you entered. You can call your GetCompanyProperties
method from there.

Hope I'm barking up the right tree here. Good luck.

- Ed

I tried what you said. Nothing happened, so I went into the debugger,
setting a breakpoint in the subroutine. What happened was and information
window telling me:

"Microsoft JScript runtime error: Object doesn't support this property or
method."

The Javacript is the one for __doPostBack that is created when you create a
master page.

The VB subroutine is:

Protected Syb GetCompanyInfo(ByVal sender as Object, ByVal e as
System.EventArgs) Handles account.Number.TextChanged

I have all the processing in this subroutine and the breakpoint is in there.
It never hits the breakpoint because of the Javascript error.

In the aspx file for accountNumber I have OnTextChanged="GetCompanyInfo" and
AutoPostBack="True"

Shelly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top