getting focus back to the same control after post back

Hi friends!

 How the control can be set focused on the same conrol after post back from where it was generated?


12/25/2008 8:48:45 AM 91979 articles. 3 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 0

At the event of the control which causes Postback , add




12/25/2008 9:53:19 AM

in this way

protected void Page_Load(object sender, EventArgs e)


if (IsPostBack)


Control control = null;

string ctrlname = Page.Request.Params["__EVENTTARGET"];

if (ctrlname != null && ctrlname != String.Empty)


control = Page.FindControl(ctrlname);







Note this will work for all controls except buttons since  buttons do not call the __doPostBack Javascript function so the __EVENTTARGET is never set. Instead, the Buttons render as simple input type=“submit” tags. All the button does is cause the form to submit.

MAKMark as Answer if this reply helps you
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
12/25/2008 10:09:47 AM

Thanks for reply.

 Can focus be set to Hidden field?

12/25/2008 10:39:13 AM

Focus property is available to only visible controls

Hidden Field as the name suggest is never visible. Hence it does not have a Focus Property. You can use TextBox instead!!

MAKMark as Answer if this reply helps you
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
12/25/2008 10:43:16 AM

 Here a simple solution.

Just set  MaintainScrollPositionOnPostback property to true in the <%@Page %>


12/26/2008 5:23:50 AM

Similar Artilces:

how to get focus back to the scroll position on post back
I have a long page.  I want the focus to the same position when user do the postback. I tried with MaintainScrollPositionOnPostback="true"  but it is not working. I read that the smartnavigation property is no longer available in 2.0. I have the application with master page. Unless you've defined a separate region within your page, it should work.  See the following for similar discussion.

How To Get Back Data from Back up After Get Deleted
Hi,All I have This Scenario I have First Taken The backup of my database named Test.bak I want to tel u initially that I have Recovery Model Full and I have Taken backup with option Full Back Up  After Taking Back Up I have Created a table and then I have inserted 6 rows In that After That I have deleted two rows from that .Now inth last I want to get back my those two rows thrugh that datbase back up   Go CReate Table Test (id int , [name] varchar(20)) GO insert into Test select 1,'Abc' union all select 2,'Def' union all select 3,'Ghi'...

Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

How to get value from dynamic control on Post-back
Hi All, This is my first post. The problem is about dynamic control. 1. In Page Load, I auto generated a datagrid.  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim lmws As New LIMSWSV10.LIMSService         Dim ds As New DataSet         If Not IsPostBack Then             ds = lmws.GetResultValueForShippingJob(Request.QueryString("ShippingJobID")) ...

Getting control value inside the grid at the post back
Hi,       I used the DropdownList control inside the gridview and i want to retrive the value of dropdown in gridview at the page postback. Is it possible to get the value using "Request.Form"? or is any other method to reteive the value?. Looking for help   Thanks  Dropdownlist ddl = (Dropdownlist)gridview1.rows[gridviewrowno].FindControl("dropdownlistid");string selvalue  = ddl.SelectedValue; in above you have to change  gridviewrowno to the rowno you wants to retrieve.dropdownlistid to the id of the dropdownlist in...

How to get table control values on post back event?
Hi, I am using table control in, there are 3 columns in the table, values of first two columns are added manually at design time and third column has text box where user needs to add values. On button click event i need to save table (cell) values of column2,column3, but some how on post back event values are disappearing in the table. There is no limit on rows, it can be one or 20 depends on user selection. Is there any way to save table values on post back event or can i disable post back event for button so that table values will not be disappeared? Thanks ...

Value of Control created dynamically is not getting populated on post back
Hi I am creating a table at run time. If I put some value to textbox, its not getting populated after post back. If I do it on Page onInit event everything works fine.. but I cant do this as I have to make rows on button click. The code is like this Sub MakeTable() Dim ht As New Hashtable ht("1") = "1" ht("2") = "2" For i As Integer = 0 To 2 Dim tr As New TableRow For j As Integer = 0 To 1 Dim td As New TableCell Select Case (j) ...

ICallbackEventHandler + get new images to my controll without post back
Hi Am struck with a problem where i want to use the "ICallbackEventHandler Interface " and get the power of "no postback processing". And that "GetCallbackResult function" returns only a string. But i want to get a image from the server which changes on each request for the user. Other controlls dont i need not refresh whole page. please help me how to get thru this ? Advance thanks Arif...

Going back to a control after post back?
I have a page that is quite long, so after each post back, user need to scroll back to that control, is that a way to tell the browser to goto that specific control after postback? I have tried to put an anchor <a name='foo'> in front of that control and use's [Page.RegisterClientScriptBlock] to insert a javascript location.href = '#foo' into the page, however, it didn't work with Netscape7 because somehow NS stop show the page after that piece of javascript is inserted to the is an example.... <html> <head> <script language='JavaScrip...

Getting things back in Start Page and things out of Start Page
I know I posted over a year ago about this same question, I can not find my original post though. I know I posted it and I did find the solution and posted the sollution but I can not find it anywhere here again. They really need a better search engine on these forums. Is there any tools out there to help manage the start page? For example. I have projects that are on a web server I access them on the remote server. Well the start page never ever shows any updates for it the date posted as last access is the day I created it, However this is one of my more used projects. This one is so b...

Question on Post back. Post back to WHAT???
   Hello I am learning about I know that Postback refers to a page being submitted to the web server. But, what is meant when a pages "Posts back to itself" ??? Is this the same thing as the single word Post Back. I ask this, because from what I have read, View State works only if a page "Posts back to itself". Does this terminology refering to a single post back to the server, or a round trip. Please help.     When a page does a PostBack, it basically does a form submit back to itself. All controls/variables are re-instantiated, and then re-populated from...

Page gets post back again and again
I have added an update panel and needs to update some other field on the basis on value of text box. The textbox is binded to Calender extender, I have written the text changed event of text box and made it auto post back.  Now, when ever i click inside the text box, my page is getting posted again and again   here is the sample code   <form id="form1" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="aa" runat="server&q...

Getting Start Page back
Anyone know if there is a way to show the Start Page again after you close it? Hi, You can try: Help | Show Start Page Regards,...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

Web resources about - getting focus back to the same control after post back -

Will Cygnus Finally Fly Today? Watch LIVE!
It’s proving hard for the Cygnus spacecraft to get off the ground for its return-to-flight mission! After getting rained out Thursday and shoved ...

Playing out the College Football Playoff: Sooners top Tide for title
Washington Post Playing out the College Football Playoff: Sooners top Tide for title Clemson enters the second College Football ...

Islamic State claims responsibility for Aden assassination
Los Angeles Times Islamic State claims responsibility for Aden assassination Los Angeles Times Yemenis inspect the scene of a car bomb attack ...

Stabbing Mistaken For Art At Art Basel Miami Beach
A stabbing was mistaken for performance art at Art Basel on Friday night. The incident took place inside the Miami Beach Convention Center, ...

Arnold Schwarzenegger: Climate Change Hard On The Brain, Global Warming Fight Needs China And U.S. To ...
According to former California governor Arnold Schwarzenegger, climate change science is very difficult for the average brain to understand. ...

Former President Jimmy Carter Announces He's Cancer-Free
Jimmy Carter has announced that his latest scan showed no signs of cancer. According to the Atlanta Journal-Constitution , the 91-year-old former ...

Trump, GOP candidates call for more surveillance
GOP candidates critique the administration's counter-terrorism policies ahead of Sunday's speech by President Obama.

The Best & Worst Sketches from Ryan Gosling’s ‘Saturday Night Live’
Kicking off the final three episodes of Saturday Night Live that we’ll get in 2015, The Notebook and Drive star Ryan Gosling took the stage at ...

Morgan Freeman’s Plane Crash Leaves Actor And SJ30 Jet Pilot, Jimmy Hobson, Unscathed
A private plane carrying actor Morgan Freeman and pilot Jimmy Hobson made an emergency crash landing in Tunica, Mississippi on Saturday. Fortunately, ...

Has Anyone Seen The Star Wars Toyota Celica? Seriously, It's Missing
When the first Star Wars movie came out in 1977, Toyota had a Celica painted and sticker’d up with Darth Vader and friends (technically enemies, ...

Resources last updated: 12/6/2015 9:15:25 PM