473,789 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnTextChanged prefire?

I think I already know the answer to this but here goes. I've read the other
postings but no solutions for this.
If a user enters a textbox, there is no 'onenter', etc. to control firing
off a sub, etc. We have OnTextChanged. But it doesn't fire until focus is
placed somewhere else.
The issue is that on my form if a user changes a textbox but goes to 'Save'
the form, the 'Save' button gets the focus and fires event OnTextChanged but
stops its true calling to submit form. The user has to press it twice and
that's just plain unacceptable.

Any workarounds? or missing something? Thanx.
Nov 19 '05 #1
4 2594
I am not sure exactly what you are asking for but you can easily create
your own PostBack event either by using a secondary invisible code and
then attaching it manually using ControlName.Att ributes.Add method or
you could register a PostBackHandler and handle it that way also. After
that it merely becomes a matter of finding out exactly what javascript
event you want it fired upon.
e.g.
myServerTextBox .Attributes.Add ("onchange",
GetPostBackClie ntEvent(Invisib leControl, ""); or alternately
myServerTextBox .Attributes.Add ("onchange",
GetPostBackClie ntEvent(myServe rTextBox, "onchange") ;
And then either through your IPostBackHandle r or by hacking and
looking at the EventArgument in the Textbox's postback handler event

String EventArgument = this.Page.Reque st["__EVENTARGUMEN T"];

if (EventArgument= =null) { EventARgument = ""; }
EventArgument = EventArgument.T oLower();
switch(EventArg ument)
{
case "onchange" .... break;
case "onlosefocu s": ... break;
}

etc
I would definitely see if what you can do can be done without a
postback event as postback events upon key clicks is extremely annoying
and probably one of the biggest bastardizations brought to the net by
asp.net

Nov 19 '05 #2
i assume you have autopostback set on the text control. this works by client
script catching the onchange event and firing a form submit. if the user
clicks on the submit button, the browser detects that a form submit is in
progress and doesn't fire the submit button submit, and as the submit is in
progress, the submit values cannot change.

the workaround is not too complex, just a little client code. on textbox,
onchange use a timer to fire the __dopostback. when the button is clicked
set a variable that a postback is started. in the timer routine do nothing
if the submit button fired.

register as startup script (change names).

<script>

window.cancelAu toSubmit = false;
document.getEle mentById('textb ox1').onchange = function () {
window.setTimeo ut("if (!window.cancel AutoSubmit )
__doPostBack('t extbox1')");
}
document.getEle mentById('butto n1').onclick = function () {
window.cancelAu toSubmit = true;
}
</script>

though i'd look at using autopost on a text field as a suspect coding style.

-- bruce (sqlwork.com)

"Chris" <Ch***@discussi ons.microsoft.c om> wrote in message
news:F0******** *************** ***********@mic rosoft.com...
| I think I already know the answer to this but here goes. I've read the
other
| postings but no solutions for this.
| If a user enters a textbox, there is no 'onenter', etc. to control firing
| off a sub, etc. We have OnTextChanged. But it doesn't fire until focus is
| placed somewhere else.
| The issue is that on my form if a user changes a textbox but goes to
'Save'
| the form, the 'Save' button gets the focus and fires event OnTextChanged
but
| stops its true calling to submit form. The user has to press it twice and
| that's just plain unacceptable.
|
| Any workarounds? or missing something? Thanx.
Nov 19 '05 #3
what exactly do you mean "suspect coding style"?
Do you offer another solution for stamping an area on a form based on the
user making changes.

i.e. I have 6 textboxes that each resepctively have their own 'changed by
and when' label (thus saved) on one form. So if a user makes a change in one
of these 6 textboxes the 'OnTextChanged' then sets the label with the user id
and date/time. These same labels are displayed if a user enters the form in
'modify' mode.

I'm open to ideas if you have solutions.

"bruce barker" wrote:
i assume you have autopostback set on the text control. this works by client
script catching the onchange event and firing a form submit. if the user
clicks on the submit button, the browser detects that a form submit is in
progress and doesn't fire the submit button submit, and as the submit is in
progress, the submit values cannot change.

the workaround is not too complex, just a little client code. on textbox,
onchange use a timer to fire the __dopostback. when the button is clicked
set a variable that a postback is started. in the timer routine do nothing
if the submit button fired.

register as startup script (change names).

<script>

window.cancelAu toSubmit = false;
document.getEle mentById('textb ox1').onchange = function () {
window.setTimeo ut("if (!window.cancel AutoSubmit )
__doPostBack('t extbox1')");
}
document.getEle mentById('butto n1').onclick = function () {
window.cancelAu toSubmit = true;
}
</script>

though i'd look at using autopost on a text field as a suspect coding style.

-- bruce (sqlwork.com)

"Chris" <Ch***@discussi ons.microsoft.c om> wrote in message
news:F0******** *************** ***********@mic rosoft.com...
| I think I already know the answer to this but here goes. I've read the
other
| postings but no solutions for this.
| If a user enters a textbox, there is no 'onenter', etc. to control firing
| off a sub, etc. We have OnTextChanged. But it doesn't fire until focus is
| placed somewhere else.
| The issue is that on my form if a user changes a textbox but goes to
'Save'
| the form, the 'Save' button gets the focus and fires event OnTextChanged
but
| stops its true calling to submit form. The user has to press it twice and
| that's just plain unacceptable.
|
| Any workarounds? or missing something? Thanx.

Nov 19 '05 #4
I tried to respond yesterday but the MSDN website crapped out again, I love
this site but it's stablity is getting worse.

Question: Why isn't OnTextChanged really 'Onchange'? It's really 'lostfocus'
becasue it doesn't fire until focus is lost!
I'm running a routine to update a label field (see response trail for more
info). But since the firing of this routine occurs once the button is
pressed, thus losing focus on a textbox, it stops the 'submit'.

I really need some sort of true onchange. I've tried onfocus but that's not
really correct since the user might enter but not change. Please read the
trail for more detail. I'd love to get your take on what I'm trying to
accomplish, thanx.

"re****@communi ty.nospam" wrote:
I am not sure exactly what you are asking for but you can easily create
your own PostBack event either by using a secondary invisible code and
then attaching it manually using ControlName.Att ributes.Add method or
you could register a PostBackHandler and handle it that way also. After
that it merely becomes a matter of finding out exactly what javascript
event you want it fired upon.
e.g.
myServerTextBox .Attributes.Add ("onchange",
GetPostBackClie ntEvent(Invisib leControl, ""); or alternately
myServerTextBox .Attributes.Add ("onchange",
GetPostBackClie ntEvent(myServe rTextBox, "onchange") ;
And then either through your IPostBackHandle r or by hacking and
looking at the EventArgument in the Textbox's postback handler event

String EventArgument = this.Page.Reque st["__EVENTARGUMEN T"];

if (EventArgument= =null) { EventARgument = ""; }
EventArgument = EventArgument.T oLower();
switch(EventArg ument)
{
case "onchange" .... break;
case "onlosefocu s": ... break;
}

etc
I would definitely see if what you can do can be done without a
postback event as postback events upon key clicks is extremely annoying
and probably one of the biggest bastardizations brought to the net by
asp.net

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4742
by: Henri | last post by:
Very strange problem : if I write: <asp:TextBox runat="server" id="myBox" /> the control's ViewState stays always empty, so it loses its properties if it's not always displayed. But if I write:
3
3549
by: Neil | last post by:
Hi, I have a datagrid containing a number of item templates, inside of these item templates I have various controls like the textbox. The user is able to edit all the fields on the datagrid at once and then click an update button. I'm trying to use the OnTextChanged event to capture which rows where updated before I update the DB. I have added the line OnTextChanged="RowChanged" to my text box control in the HTML and added the event...
2
1438
by: Neil | last post by:
Hi, I currently have a datagrid with template columns containing textboxes etc. The textboxes are in the item template so the whole grid is editable by default, I then have a general update button to update the whole grid. I'm using the example under http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp I'm using the OnTextChanged event to capture which...
3
11781
by: kbrandl | last post by:
On my page, there is a textbox at the top that contains a date -- and a fully-editable datagrid below (each row in the datagrid contains an editable textbox, along with some other controls). The date textbox is defined as: <asp:TextBox EnableViewState="True" ID="HoursWorkedDate_TextBox" Runat="server" width="80px" CssClass="inputstyle" onBlur='javascript:Search.submit();' OnTextChanged="Date_Changed" />
1
16543
by: Alex Nitulescu | last post by:
Hi. I have created a web-based file manager. Now I'd like to watch a folder for changes, and when a change occurs I'd like to refresh my page. Okay. So I have created a FileSystemWatcher set on the folder I need to watch. It works fine. The problem occurs when I need to trigger an automatic Refresh. So I added two handlers - OnChanged and OnRename, in the same class as my filemanager.
1
2756
by: mdipiet | last post by:
I've got a form that is supposed to validate data entry from a bar code scanner. The scanner is set up to add a carriage return at the end of the data in the barcode, which should fire the onTextChanged event to validate the information recieved; however, the Enter key does not fire this event as it should. Can anyone give me some help as to why the Enter key won't fire the onTextChanged event? Matt
4
7401
by: MattB | last post by:
Hi. I'm working on an intranet application that requires a user to input information about themselves. I have a user control with a couple of textboxes that I want the user to enter their weight into. One is for Lbs and one is for kg and I'm using the OnTextChanged event to populate the other control if one is filled in (converting between kg and Lbs). It works, but when one TextBox is changed and it sets the other's value, the second...
0
1447
by: RajS | last post by:
Hi All, I am trying to update datagrid, onTextchanged event, I dont know how to do this. please shed some light or any examples. Here is the code I am wrestling with. OnTextChanged event of Textbox1 I want to pass price and ID to this event, how can I pass? //DataGrid html code <asp:TextBox id="Textbox1" Text='<%#
1
4908
by: Fred Dag | last post by:
As far as I can work out when using the OnTextChanged event I cannot get the TextBox and Labels values when the event fires as they are populated by a <asp:repeater and so don't have values. If I try to give the repeater values by removing if (!IsPostBack) {} from the
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9984
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.