Hi,
Is it possible to retrieve the control that had the focus when the page was
posted back?
Because the focus is lost when a postback occurs I want to manually set the
focus to the control that previously had the focus (smartnavigatio n doesn't
do the trick).
Thanks, Marco 2 5185
use javascript
once the page hits the browser, .net is no longer at play
eg, object.onfocus( ), set some hidden field to the control's name
once the page is back to the browser, use javascript again to set focus
it's a lot of work but that's the only way i've found that works. just
be careful about objects no longer being on the form or being disabled.
Marco Liedekerken wrote: Hi,
Is it possible to retrieve the control that had the focus when the page was posted back?
Because the focus is lost when a postback occurs I want to manually set the focus to the control that previously had the focus (smartnavigatio n doesn't do the trick).
Thanks, Marco
Here's a C# function you can call to have a page set focus when the page is
displayed:
protected void SetFocus(WebCon trol wc)
{
StringBuilder sScript = new StringBuilder(" ");
sScript.Append( "<script language='javas cript'>");
sScript.Append( " document.getEle mentById('" + wc.UniqueID + "').focus() ");
sScript.Append( "</script>");
Page.RegisterSt artupScript("Fo cus", sScript.ToStrin g());
}
All you need to do is call this function before posting the page. Should do
what you need.
"Kairi Zikpin" <zikkai.nospam. @netscape.net> wrote in message
news:3F******** ******@netscape .net... use javascript once the page hits the browser, .net is no longer at play
eg, object.onfocus( ), set some hidden field to the control's name once the page is back to the browser, use javascript again to set focus
it's a lot of work but that's the only way i've found that works. just be careful about objects no longer being on the form or being disabled.
Marco Liedekerken wrote: Hi,
Is it possible to retrieve the control that had the focus when the page
was posted back?
Because the focus is lost when a postback occurs I want to manually set
the focus to the control that previously had the focus (smartnavigatio n
doesn't do the trick).
Thanks, Marco
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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: RTM |
last post by:
Can anyone help me with the following issue? I've seen some similar
questions here, but none relating to a textbox control....
I have a form with several controls, one of them being a textbox
control with AutoPostBack set to true. I need to fire a method ONLY
when the form has posted back due to a button click (no problem here),
or from the user typing text in the text box and hitting enter. I
can't call this method from any postback,...
|
by: Ian Oldbury |
last post by:
i do a postback on a field within a dot.net datagrid (in editmode) and need
to set the focus to a specific field within the grid. Has anyone done this,
any suggestions?
|
by: Dexter |
last post by:
Hello All,
I have a web control that when receive the focus, a postback is called,
using getPostBackEventReference. But, when the PostBack is called, i want
that the focus goes to the web control.
Somebody know how to make this?
Dexter
|
by: djc |
last post by:
I noticed that after entering text into a textbox on an asp.net webform and
then hitting the enter key that a postback appears to be performed.
1) what event can I write to in order to perform an action at that time?
2) How can I prevent any postback from happening on textboxes that I do not
want to handle this event on?
any info is appreciated. Thanks.
| |
by: Chris |
last post by:
Hi,
I am trying to create a popup calender so a user can click on a button on
the main form, a calender will then popup, the user will select a date and
then click ok on the popup. The date will then be passed back to the main
form and populate a textbox. I tried two options. None worked.
First. I used the popup calender form the time tracker starter kit. On my
page I have an image buton. In the click event I have the foll code
|
by: clickon |
last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains
a text box, TextBox1 and TextBox2 respectively. If i put the following code
in the respective activate event handlers for the two steps,
TextBox1.Text ="foo";
and
TextBox2.Text = "bar";
|
by: amjad |
last post by:
Hi i need to write javascript to shift control focus ..... like if i enter in
textbox 1 then it set focus to textbox2 or 3 any thing ...
the other thing is how i know i can do like
mytextbox.atrribute.add("OnClick","return myfunc()");
but if i want to use enter instead of onclick ... thanks
|
by: John Smith |
last post by:
How can I find out which control performed PostBack?
I have put this code inside my Page_Load event:
Response.Write(Page.Request.Params.Get("__EVENTTARGET"))
but it doesn't write to response anything when I click on the button inside
DataGrid (my asp:Button is located inside my template column togrther with
my asp:TextBox). It works fine for DropDownList, which is also inside
template column inside DataGrid.
|
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...
|
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: 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...
|
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: 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();...
|
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...
| |