I'm setting focus depenting upon which field has changed value. I'm doing
this with the following: Page.RegisterSt artupScript("Se tFocus", "<script
language=""Jscr ipt"" > document.getEle mentById(""txtC ity"").focus() ;
</Script>"). This is being called on the textChanged event for textboxes. for
city it goes to state for state it goes to zip, ...
It works, but is this the correct way to do this or should this be a seties
of if then else's in he page load? if so, how can i isolate the textbox that
caused the event?
thanks
kes 3 4620
You can change the javascript you have below to generate the name of the
control that caused the event:
Page.RegisterSt artupScript("Se tFocus", "<script language='Jscri pt'>
document.getEle mentById(" + controlName + ").focus(); </Script>").
in the "Changed" event of the control just set the "controlNam e" variable to
the required javascript id for the control:
i.e. for the txtCity changed event:
controlName = "txtCity";
I'm assuming that you are calling the Page.RegisterSt artupScript() function
in the "Render" event of the page - you'll need to remember that because the
"Render" is called after the "Changed" event and thats what you want, if you
put the Page.RegisterSt artupScript() in the Page_Load() by mistake, then the
"controlNam e" variable will not be assigned a value yet.
"Kurt Schroeder" wrote: I'm setting focus depenting upon which field has changed value. I'm doing this with the following: Page.RegisterSt artupScript("Se tFocus", "<script language=""Jscr ipt"" > document.getEle mentById(""txtC ity"").focus() ; </Script>"). This is being called on the textChanged event for textboxes. for city it goes to state for state it goes to zip, ... It works, but is this the correct way to do this or should this be a seties of if then else's in he page load? if so, how can i isolate the textbox that caused the event?
thanks kes
Thank you for replying!
i have the function call in each of the respective controls' changed event:
Example:
Private Sub txtbAdr1_TextCh anged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles txtbAdr1.TextCh anged
If chkShipSame.Che cked Then
txtSadr1.Text = txtbAdr1.Text
Page.RegisterSt artupScript("Se tFocus", "<script
language=""Java script"" > document.getEle mentById(""txtb adr2"").focus() ;
</Script>")
End If
End Sub
In vS.net i could not find the Render event under page, but i'm still
learning this. as well as JavaScript. I see PreRender, but not render.
1. My guess is the funtion calls are not in the right place, but should only
be one function call in the Render event?
2. where can i find Render?
3. the controlname variable is this a simple .net string variable or a
javascript variable?
Thanks
kes
"Jorge L Matos [MCSD.NET]" wrote: You can change the javascript you have below to generate the name of the control that caused the event:
Page.RegisterSt artupScript("Se tFocus", "<script language='Jscri pt'> document.getEle mentById(" + controlName + ").focus(); </Script>").
in the "Changed" event of the control just set the "controlNam e" variable to the required javascript id for the control:
i.e. for the txtCity changed event:
controlName = "txtCity";
I'm assuming that you are calling the Page.RegisterSt artupScript() function in the "Render" event of the page - you'll need to remember that because the "Render" is called after the "Changed" event and thats what you want, if you put the Page.RegisterSt artupScript() in the Page_Load() by mistake, then the "controlNam e" variable will not be assigned a value yet.
"Kurt Schroeder" wrote:
I'm setting focus depenting upon which field has changed value. I'm doing this with the following: Page.RegisterSt artupScript("Se tFocus", "<script language=""Jscr ipt"" > document.getEle mentById(""txtC ity"").focus() ; </Script>"). This is being called on the textChanged event for textboxes. for city it goes to state for state it goes to zip, ... It works, but is this the correct way to do this or should this be a seties of if then else's in he page load? if so, how can i isolate the textbox that caused the event?
thanks kes
Sorry, I meant the "PreRender" event, not the "Render".
Answers:
1. Yes, but use "PreRender" not "Render"
2. Don't worry about Render
3. The controlName variable is a field of the "Page" class that you create
and all the "Change" events can set it to the javascript ID of the control.
The page events are typically executed in the following order:
a) Init
b) Load
c) Change Events
d) Click Events
e) PreRender
f) Render
REF: http://msdn.microsoft.com/library/de...nlifecycle.asp
ASP.NET 2.0 will have an enhanced page event life cycle with more events
that you can hook into.
"Kurt Schroeder" wrote: Thank you for replying!
i have the function call in each of the respective controls' changed event: Example: Private Sub txtbAdr1_TextCh anged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtbAdr1.TextCh anged If chkShipSame.Che cked Then txtSadr1.Text = txtbAdr1.Text Page.RegisterSt artupScript("Se tFocus", "<script language=""Java script"" > document.getEle mentById(""txtb adr2"").focus() ; </Script>") End If End Sub
In vS.net i could not find the Render event under page, but i'm still learning this. as well as JavaScript. I see PreRender, but not render. 1. My guess is the funtion calls are not in the right place, but should only be one function call in the Render event? 2. where can i find Render? 3. the controlname variable is this a simple .net string variable or a javascript variable? Thanks kes
"Jorge L Matos [MCSD.NET]" wrote:
You can change the javascript you have below to generate the name of the control that caused the event:
Page.RegisterSt artupScript("Se tFocus", "<script language='Jscri pt'> document.getEle mentById(" + controlName + ").focus(); </Script>").
in the "Changed" event of the control just set the "controlNam e" variable to the required javascript id for the control:
i.e. for the txtCity changed event:
controlName = "txtCity";
I'm assuming that you are calling the Page.RegisterSt artupScript() function in the "Render" event of the page - you'll need to remember that because the "Render" is called after the "Changed" event and thats what you want, if you put the Page.RegisterSt artupScript() in the Page_Load() by mistake, then the "controlNam e" variable will not be assigned a value yet.
"Kurt Schroeder" wrote:
I'm setting focus depenting upon which field has changed value. I'm doing this with the following: Page.RegisterSt artupScript("Se tFocus", "<script language=""Jscr ipt"" > document.getEle mentById(""txtC ity"").focus() ; </Script>"). This is being called on the textChanged event for textboxes. for city it goes to state for state it goes to zip, ... It works, but is this the correct way to do this or should this be a seties of if then else's in he page load? if so, how can i isolate the textbox that caused the event?
thanks kes This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Miquel |
last post by:
Hi all.
I felt frustrated when developing an 'UserControl' derivated from
textBox, because sequence event (and Validate event) seems to fail.
I Always thought my code was wrong. But after trying the UserControl a
lot of hours I have the feeling that c# (or .Net) fails.
Thus, I have developed a simple program with 3 textBox, 1 Botton and 1
ListBox (for showing results) which fire OnEnter, OnGotFocus,
|
by: Elliot M. Rodriguez |
last post by:
Is it possible to change a control's focus at runtime? I'm sure you can....
I have a form with 2 textbox controls that cause postbacks. They are located
in the middle of my form.
When a postback occurs, no control has the focus. I would like it to be so
that the control that causes the postback keeps the focus. Since I have 2
controls that potentally need to retain focus, using Javascript in this case
is a PIA.
|
by: Sheila Jones |
last post by:
Hello,
I have a couple of textbox controls which each fire TextChanged events.
AutoPostBack is false for both controls, so the events only actually fire
when another control causes a postback. However, the TextChanged events
always seem to happen in the same order, regardless of which box was changed
first.
Is there any way to ensure that the events fire on the server in the same
order they occurred in the browser (other than setting...
|
by: Mark Lingen |
last post by:
I've found a problem with postback event handling and webcontrol
buttons. Try out the following code in an ASP.Net project and you
will see. Create a web project in VB.Net and drop this code ontop of
the webform1:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
|
by: Rob Shorney |
last post by:
Hi,
I have a number of text boxes on my web form. when the text is change the
serverside event TextChanged gets raised and I do some server side
validation. This is fine.
However, when the event has finished processing, I would expect focus to be
returned to the next textbox on the page - this does not happen.
My question is, how can I programatically in code behind set focus to a
| |
by: SJ |
last post by:
Hi all,
I have come across a weird problem when attempting to automatically
set the focus in a vb.net form to a checkbox control...
In my form I have (on a tab page in a tab control) several textboxes
and a checkbox. The behaviour I want from my app is as follows:-
When the textbox (which is prior in tab order to the tab control) has
been filled with a certain length of text by the user, the focus is
|
by: Finn Stampe Mikkelsen |
last post by:
Hi
How can i set a focus to a textbox in my codebehind page??
I have this WebForm, that takes information from a user and 2 buttons on the
form. One that takes action on the entered information and one that resets
the form...
The second on, the reset button, i would like to set focus back to the first
textbox on the form. I already have an onload in my body, which sets the
|
by: Mel |
last post by:
I have several text boxes and drop-down lists in an AJAX Update
Panel. All user inputs have the Postback property set to True. After
I type something in the first input entry and press the "Tab" key how
can I set the focus to the next box after the postback? Please help!
Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
|
by: Peter |
last post by:
ASP.NET
I have an application which use ASP.NET Autocomplete extender which works
great. But I have a question how to update all the fields on the screen
using Ajax.
Users starts typing in a text field which causes the Autocomplete extender
to display 10 like items, after the users selects an item (which is a key in
the database) I want the application to go to the database retrieve a record
and populate the fields.
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |