Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










C# - AutoPostback Not Setting Focus Correctly?


I have a page that when auto or partial post back happens, focus is set to the address bar rather than the next control. The interesting thing is that when I put an alert in my RadScriptBlock, after the OK is clicked, focus goes to the correct control -or- if I put in an invalid location, focus is returned to the ExpLocation control & when a correct location is input the second time, the tab order/focus command works correctly (see code below).

That has this up top

[code].....


View 2 Replies (Posted: Dec 29 10 at 18:47)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Web Forms :: How To Get AutoPostBack Working Correctly With User Control
I have an AJAX enabled ASP.Net 3.5 app in which I have:

A Master PageA Web Content PageA User ControlMore precisely, there's a Placeholder control in the Web Content Page into which one of many User Controls are loaded (one at a time or none at all).

The basic User Control I'm working with has a bunch of Labels and one DropDown ListBox. The latter control is a date selector - ie. June 2010, May 2010, April 2010, etc. When the user changes the date, since AutoPostBack = true for the control, a PostBack occurs. But when this happens, the User Control disappears!

All I want is for a partial postback to occur so that I can use the new date to repopulate the various Label controls. I even put the Placerholder control in its own UpdatePanel but this didn't resolve anything - the User Control still disappeared.

Posted: Jun 08, 2010 12:07 AM

View 7 Replies!   View Related
Web Forms :: Focus Other Textbox After AutoPostBack?
I have 5 textboxes in aspx page, and theirAutoPostBack property is True. When I write something tofirst textbox and press tab keytowrite somethingto second textbox, the second textbox don't be focused. Ihave to select second textbox with mouse to write something it. I want to focus the second textbox by pressing tab key after write something to first textbox. HOW Can I do this?

Posted: Feb 04, 2010 03:56 PM

View 6 Replies!   View Related
Web Forms :: Autopostback On Textbox That Loses Focus?
I have a webform that the user inputs a date via a javascript popup calander, then it auto populates a textbox with 45 days after the inputed date.

My question is is there a way to have a postback once the input date loses focus. Here is my page.

ASPX

[Code]....

C#

[Code]....

Posted: Feb 23, 2011 08:34 PM

View 5 Replies!   View Related
AJAX :: Losing Focus After AutoPostBack In UpdatePanel?
I have a checkbox inside an update panel with its AutoPostBack value set to true. When I click it, it performs the postback operation successfully but then loses the focus. I've tried setting a variable to store the value but the Page_Load event just sees a null value there. I need to be able to preserve the focus after a partial page postback and it's just not working right now.

Posted: Feb 21, 2007 01:58 AM

View 12 Replies!   View Related
Web Forms :: Controlling Focus On Form With AutoPostBack TextBoxes?
Ihave a form with several textboxes. All of these have AutoPostBack="True".

My problem is that the focus disappears to goodness knows where after each postback. The behaviour I would like to enforce is as follows,

If the user hits the Enter or Tab key after filling in a textbox then the focus should go to the next field on the form (to be explicitly specified in my code).

If the user clicks ontextbox Xafter filling in textbox A then the focus should go to textbox X after postback, even if it isnot the next in the list.

In other words, I want the form to behave in the way that most users would intuitively expect.

I have Googled for potential solutions to the loss of focus after postback but the few that I have found were many years old and I am unsure that the advice is still relevant for ASP.NET 4.0.Some of these old solutions also appeared to beinvalid for browsers other than IE. What is the current best practice for handling this issue?

BTW, VB.NET solutions are preferred though I will also be happy to accept C# suggestions (which I would run through a code converter). Note that I have a single sub in my code for handling the TextChanged events forall my textboxes.This means that I have to usethe following code to work with the textbox that has called the sub.

Dim CurrentTextBox
As
TextBox =
DirectCast(sender,
TextBox)

If addressing the focus problem means that I have to have individual TextChanged event subs for each textbox then so be it, but I prefer the simplicity of my current single sub approach.

Posted: Oct 29, 2010 12:39 PM

View 9 Replies!   View Related
Forms Data Controls :: Set Focus After Gridview Dropdownlist SelectedIndexChange Autopostback?
I have a Gridview that provides the user the student name for a particular class, a dropdown list to enter grades. If a grade of 'U' is given, a textbox appears in which the last day of attendance must be listed.

It works... though not as conviently as it could; the faculty would like to be able to tab from one dropdownlist to next in succession.

On each ddlGrades changes I write the value to the database and if a 'U' was chosen, display the textBox... but I can't figure how to set focus on the next ddlGrades control, or even the same ddlGrades control that initiated the postbock.

Below is my simplified .aspx followed by the codebehind

[Code]....

Posted: Feb 16, 2010 09:29 PM

View 4 Replies!   View Related
Web Forms :: Setting Focus To Web Control
Can anyone give mesomeVB to set focus to a control using the "FindControl" method. MyTextbox.focus() is not good enough because, for instance, I have a textbox called "Username" in the "CreateNewUserWizard" control which is within a Contentplaceholder on a child page so typing in "Username.focus()" does not work on the Page_Load event because Username simply does not have a Focus property.

Posted: Jun 30, 2010 03:52 PM

View 1 Replies!   View Related
Setting Focus To A Textbox Using Vb.net / 2005
using vb.net/asp.net 2005 after the user clicks on a button in the buttonClick event I am trying to set the focus at the end of the function simply as follows:

[Code]....

However the focus is instead going to another button. The tabIndex property is not set on any controls on the page.

Posted: Oct 21, 2010 07:02 PM

View 9 Replies!   View Related
Web Forms :: Setting The Focus On A Text Box
How do I set the focus on a text box in a web form? I have a child page derived from a master page. The child form contains 3 textboxes and one button. I need to set the focus to the first textbox.

Posted: Nov 10, 2009 01:44 PM

View 2 Replies!   View Related
Web Forms :: Setting Focus On Postback?
I am using update panel and I have a form which has dropdownlist for states. Once some1 selects the states, tax gets updated. Now wht I want is on post back I shd be able to set focus on textbox (zip code) after some1 has selected state.

Posted: Oct 05, 2009 09:13 PM

View 4 Replies!   View Related
Setting The Focus On Popup Panel?
I use a modalpopupextender to show a popup when the user clicks on a button.

<ajaxToolkit:ModalPopupExtender ID="mpe1" runat="server" TargetControlID="statusInfoLb" PopupControlID="statusInfoPanel" DropShadow="false"
OkControlID="okBtn" OnOkScript="onOk()">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="statusInfoPanel" runat="server" Height="185px" Width="454px" SkinID="Panel_Notification2" DefaultButton="okBtn">

The panel has an OK-Button to dispose the popup. It is also possible to click Return to dispose the popup, because the panel has the property DefaultButton="okBtn".

But this only works when the popup has the focus, which is not so from the start. How do I get the popup panel to have the focus when it shows? I would like to use jQuery.

Posted: Apr 19 10 at 14:05

View 1 Replies!   View Related
Setting The Application Focus On Other Areas Of A Form?
I am not sure how to explain my current issue. Right now I have a Form that spans a couple of pages. I have divided the Form into multiple section as well including a File Upload section, a File Download section, and have an 'Update' button at the bottom of the Form. I also have Error labels within each section, and have an Error label at the bottom of the Form under the 'Update' button.The problem that I am experiencing right now is that when I produce one of these errors, the Form automatically displays the very top of the page. So in other words, if the error message is displayed at the bottom of the Form, the user has no idea unless they scroll all the way down.Is there anyway to keep the application focus at the area where the button is clicked on? This way if the user produces an error, they will see it right away.

Posted: Jun 24th, 2010, 10:50 AM

View 4 Replies!   View Related
Setting The Focus At End Of Text In A Textbox-element?
Is it possible with easy options in ASP.NET to set the focus at end of text in a textbox-element ? Without JavaScript ?

Posted: Nov 4 10 at 12:51

View 1 Replies!   View Related
Web Forms :: Data Loading And Focus Setting
In page_load, I used code below to load data to a Gridview and set focuson txtOrderNumber but never get focus working.

If Not Page.IsPostBack Then
--- code to load data to a gridview
end if

txtOrderNumber.focus() But, if only code txtOrderNumber.focus() Focus is working. How to fix it so that data can load and focus can set?

Posted: Nov 04, 2009 03:27 PM

View 1 Replies!   View Related
MVC :: Setting The Focus To A TextBox On Page Load
In my markup, in addition to a number of other controls I have the following:

<%:Html.TextBoxFor( m => m.UserName)%>

I'd like to be able to set the focus to this textbox when the page is loaded. Is there a really easy way to do this? I have to admit that so far I haven't found it. I know that I can do this using something like this JQuery/Javascript code: $('#UserName').focus();

However, I don't like the fact that the model field name 'UserName' has to be expressed as a string constant again here - it smells of a maintenance problem. I'd really like to be able to reference the model field directly if possible. Somethiing like this: $('#' + '<%:Html.ModelFieldNameFor(m => m.UserName)%>').focus();

Posted: Jan 11, 2011 08:48 PM

View 2 Replies!   View Related
AJAX :: Setting Focus Back On Page
I have wierd situation on my side. Ihave a page thatuses auser control driven by ajax. When Ienter a code in txtbox.Corresponding questions for that codeare brought into the middle section of page basically in user control. I have requirement of setting the focus on the controls so that I can tabout the field with feel of questions being a part of same page.

I have to manually set thefocus forthe first question and after going thru all the questions I get control lost. Basically it dont come back to the actual page. I have tried to manually put the focus on the button but I couldnt.

Posted: Jan 11, 2010 08:05 PM

View 3 Replies!   View Related
AJAX :: Setting Focus To A Textbox In Modalpopup
I have a panel which contains a textbox and a button. The panel will be shown as a modal popup using the 'modal popup extender' . I want to set the focus to the textbox in the panel when my modal pop up loads .

Posted: May 11, 2010 04:27 AM

View 4 Replies!   View Related
AJAX :: AutoCompleteExtender Breaks On Setting Focus
I have an autocomplete extender on my page and it works fine. However as soon as I set focus of its textbox via either straight javascript or codebehind the autocompleteextender no longer works.

Posted: Jun 16, 2010 02:50 PM

View 2 Replies!   View Related
JQuery :: Setting Focus To Current Item
We have an ASP.NET MVC application which uses lot of JQueries. One of them I found is following:

function (data)
{
updatePoints(function ()
{
$('#point-list>li').last().click();
});
});

This sets the focus to the last point in my list but I think its not good idea because when I click save button to update my intermediate point, it automatically set the focus to last point. I want it to stay on the same point after refresh. Is it possible to do? Is there any property like Current()?

Posted: Feb 24, 2011 01:03 PM

View 4 Replies!   View Related
AJAX :: Calendar Extender Setting Focus To Its TargetControl
i have calendar extender that has targetcontrol property set to a textbox and i want the focus to be on that textbox after the user select a date , i have tried with this OnClientDateSelectionChanged = "SetControlFocus();" in which SetControlFocus is a javascript function that set the focus to the textbox with this line document.getElementById('txtbox').focus();but it didn't work!

Posted: Aug 05, 2010 09:23 AM

View 5 Replies!   View Related
Web Forms :: Setting Focus To Validationsummary Control After Validation
I have a validationsummary control which displays the summary of a few validationrequired controls and all of them belong to a validationgroup.

My submit button also has the same validationgroup so it validates everything upon it being clicked.

The problem i am having is setting the focus to the validationsummary control after validation occurs when my submit button is clicked. The focus goes to the top of my webform.

I need the focus to be put at the validationsummary control. How do i achieve this?

FYI:SetFocusOnError="true" did not work.

Posted: Oct 28, 2009 02:04 PM

View 3 Replies!   View Related
Web Forms :: Setting Focus On TextBox Within Asp:panel And Contentplaceholder?
I have a project with several pages all using 1 master page.

I need to set focus onto a textbox either on page load or on a button click.

The textbox is in a panel on one of the child pages of the master page like this:

<asp:contentplaceholder ID="content1">
<asp:panel ID="Panel1">
<asp:TextBox ID="TextBox1">
</asp:panel>

[Code]....

I can only think its something to do with master pages or the panel.

Posted: Aug 19, 2009 08:02 PM

View 10 Replies!   View Related
Setting Focus To Textbox In Login Control On Page Load?
I am trying to set the focus to the user name TextBox which is inside an ASP.NET Login control.

I have tried to do this a couple of ways but none seem to be working. The page is loading but not going to the control.

Here is the code I've tried.

SetFocus(this.loginForm.FindControl("UserName"));
And
TextBox tbox = (TextBox)this.loginForm.FindControl("UserName");
if (tbox != null)
{
tbox.Focus();
} // if

Posted: Jun 15 10 at 8:26

View 3 Replies!   View Related
Web Forms :: Setting Focus On Page Load Doesn't Work?
I have been browing forums & googling for a couple of hours this morning, trying to find an answer to what (to me) should be a very simple issue. (I am a Delphi programmer moving somewhat reluctantly to Visual Studio C# , for web apps) I have created the simplest ASP.NET website in Visual Studio, containing a Textbox and a Button. When the website loads, I want Textbox1 to have focus. Simply doing

[Code]....

and this too does not work. However, if I press the Enter key when the webpage is displayed, then focus does move to TextBox1 (and pressing Enter again will fire any code attached to Button1). Surely it cannot be this hard to perform something so simple?

Posted: May 06, 2010 11:32 AM

View 9 Replies!   View Related
AJAX :: TabContainer Setting Focus To A Control Inside The TabPanel?
I tried different ways to set the focus in a textbox inside a Tab Panel that was inside a TabContainer, could not get it done, tried with java script, nothing.

[Code].....

Posted: Apr 20, 2007 07:20 PM

View 23 Replies!   View Related
AJAX :: Keeping The User In Appropriate Form Location - Setting Focus?
I used Ajax collapsible extenders (1 to 9) with formviews in each of them on a web form.

They are all collapsed by default. If the user enters data in collapsible 5 formview and submits data, the page refreshes back to the top of the page (where the collapsible 1 is positioned). I would like the focus to stay in the region the user is working (even after insert/submit operations). How can I do this.

Posted: Feb 01, 2011 04:29 PM

View 4 Replies!   View Related
Setting Focus On Text Field On Initial Load Of Form
I want the cursor to appear on the first text box in my screen when user goes to the site I have coded this but no cursor is placed in textbox

<form id="Form1" defaultfocus="TextboxTelephone" method="post" runat="server">

I have to tab to get cursor in first textbox telephone.

Posted: Apr 15, 2010 03:34 PM

View 3 Replies!   View Related
AJAX :: Setting Focus On ModalPoupExtender From Code Behind Show() Method?
I have figured out a method for displaying a modal popup using the ACT ModalPopupExtender from the server side.This is really important because there is a fair amount of server side initialization that I require prior to showing the dialog.

Basically, I assign a dummybutton as the TargetControlID. Then I define a link button such that when clicked it fires an OnClick event. The handler then does whatever initialization is necessary and uses the show() method of the ModalPopupExtender. This is not rocket science. However, what appears to be rocket science is getting a control within the MPE to get the cursor focus. The problem as I see it is that because I am manually showing the dialog, the JS add_shown function never fires. Of course the add_shown function is attached through JS by using the behavior ID of the MPE. It appears to be the standard way to set focus within a MPE dialog. It appears to only work if the targetcontrolid is a real button that shows the MPE dialog when clicked.

Is it possible to set the focus within a MPE dialog when you are programatically showing the dialog and not attaching a real button press event to the MPE Target Control ID? Obviously the Page.SetFocus or Control.Focus() do not work either before or after the modal dialog is shown:

protected void SignIn_Click(object sender, EventArgs e)
{
Session["InTimeOut"] = true;
Session["logintries"] = 0;
SI_user_login_id.Focus(); /// ---> This does not set the focus either before or after the show method
this.ModalSignOn.Show();
}

Posted: Feb 22, 2011 11:35 PM

View 6 Replies!   View Related
AJAX :: Setting Focus With ScriptManager Loses Page Scroll Position?
I have a textbox where a user enters a number. This control is within an UpdatePanel. I have a method that fires on TextChanged which simply checks to see if it can be parsed as a decimal and does some formatting (namely formatting it as a decimal number with 2 decimal numbers). When this method fires after tabbing out of the field I lose the focus on the next control on the form. I found a method for using the ScriptManager to manually set the focus. Here is the event handler in full.

[code]....

Posted: Feb 24, 2009 03:47 AM

View 2 Replies!   View Related
AJAX :: Odd Behavior On Setting Focus In User Control With Update Panel?
I'm having a bit of an issue in my ASP.Net application moving focus from a textbox in one user control to a text box in the next user control on the page after postback. I've searched high and low over the last several days to find a solution but, for whatever reason, have been unable to do so.

I have a page that has user controls loaded dynamically to allow a user to enter data.The number and type of user controls loaded to the page is determined at run time based on a database query.It is possible than many controls of the same type can be loaded. Each user control has its own update panel. Within the update panel of each control is a regular asp panel. Inside of the regular panel there are at least 2 server controls (any other controls that may exist in the user control are not affected by this issue) - a text box and a button.The defaultbutton property of the regular panel is set to the ID of the button within the user control. The desired behavior is to allow the user to enter data into the textbox on one user control hit enter to save the data on that user control the application will set focus to the textbox of the next user control on the page after the data from the "current" user control has been saved. Other considerations;

The application uses master pages. We make extensive use of ajax and the ajaxtoolkit in the application. I am using Visual Studio 2010 and .Net 4 The issue - when first entering the page, one can enter data into the first textbox and press the enter key. Data from "current" user control is correctly saved and focus is correctly moved to the next user control on the page.

Data can be entered into the textbox of "new" user control and when the enter key is pressed, the data is correctly save. The focus appears to move correctly to the next user control on the page.Data cannot be entered into the textbox of the control. Pressing the enter key will not save the data (because none was entered) but the focus will move to the textbox of the next user control on the page.

Data can be entered into the textbox of the user control. When the enter key is pressed, the data is correctly saved and the focus appears to move correctly to the textbox of the next control on the pageBasically, steps 3 and 4 are repeated until the end of the user controls on the page, alternating between being able to enter data and not. Other items of note When one is able to enter data into the textbox of a user control, one can correctly tab through the textboxes of each user control until the end of the page When one is not able to enter data into the textbox of a user control, pressing the tab key will take the focus to the address bar of the browser.

I created a much simplified example of the scenario described above and was able to consistently reproduce the "bad" focus behavior. All of the ajax toolkit controls and code where stripped out of the sample to rule the toolkit out as a cause. The behavior still occurs without the toolkit.

I am including the code for default.aspx and WebUserControl1.ascx.

[Code]....

[Code]....

[Code]....

[Code]....

Posted: Nov 09, 2010 09:59 PM

View 2 Replies!   View Related
Web Forms :: Setting Focus To Login W/in Panel With AJAX Toolkit Extender?
I have a page with a panel on it.Inside the panel is a login control. The panel also has the AJAX toolkit rounded corner extender. I want to set the focus to the login control on load. I add Login1.Focus() to my Page_Load but nothing happens. If I remove the AJAX toolkit rounded corner extender, all is well. The focus is set to the login control on page load. So, I suspected a container problem, I altered my code to:

[Code]....

but no joy. The focusis not set to the login on Page_Load. I even tried just referencing the main panel:

[Code]....but still no joy. help mein getting focus set to the login control that is with a panel that uses theAJAX Control rounded corner?

Posted: Nov 05, 2009 01:15 AM

View 5 Replies!   View Related
Cant Input Text To TextBox While Setting Focus In Defult Button Click Event
In set the Send button as default button in my page. In the button click event I try to set the focus to the TextBox. When clicking the button the event work fine but While clicking the enter button I cant input text to TextBox.

Posted: Feb 23, 2010 04:36 AM

View 10 Replies!   View Related
Forms Data Controls :: Setting Focus To A Control In Gridview Edit Mode?
I have a gridview with edit functionality and using the EditItemTemplate section. I am trying to set focus to a textbox when user selects the edit mode.

[Code].....

Posted: May 01, 2010 11:47 AM

View 6 Replies!   View Related
Forms Data Controls :: DataGrid - Setting Focus After A TextBox TextChanged() Event?
Asp.NET v2.0

Data grid with mulitple texboxes per row.

Each textbox has a TextChange() event wired up for data validation.

These events fire just fine, the data validation works just fine.

My issue is this: User enters text into TextBox1 one then tabs into TextBox2. The cursor appears for a split second inside of TextBox2 then disappears as focus is being set somewhere else on the page. I'm not sure how that change of focus is happening.

In this scenario, after tabbing out of TextBox1, how can I maintain focus on TextBox2 (and then subsequently TextBox3, TextBox4,etc..)

Posted: Oct 27, 2010 11:17 PM

View 5 Replies!   View Related
Web Forms :: How To Stop Autopostback For A Selected Values In Autopostback Enabled Dropdown
I am using an asp.net autopostback enabled dropdown list. Here i want to restrict the autopostback property fot the value "Select" in the ddl. I have used javascript for this purpose. but not working.My code look like this.

[Code]....

Posted: Mar 29, 2010 07:28 AM

View 10 Replies!   View Related
Forms Data Controls :: Page.setfocus(listbox.selecteditem) Is Not Setting The Focus If Index > 820?
Why I am unable to setfocusto my list box if the index > 820

My list box contains 2000 items and the index is not able to set the focus if the index > 820

Posted: Sep 13, 2010 03:12 AM

View 6 Replies!   View Related
Forms Data Controls :: Setting Focus On A Textbox In A Row When Clicking "Edit" Button?
I have a gridview with edit button. I want to set focus on a textbox in a row when clicking "Edit" button. (it is a label before clicking edit, it become a textbox after clicking edit). However, i can't set it focus in Rowdatabound. By the way, I make a simple .aspx page and just put a textbox on the tabcontainer tab panel. I found that i totally cannot set focus on this text box.

Here isaspx pagewith a text box, the .aspx page code isbelow:

[code]....

Posted: Nov 01, 2010 04:10 AM

View 10 Replies!   View Related
Web Forms :: Setting Focus On Login Button In Login Control?
i have a login control . I need to set focus on submit button, every time user pressses enter key.

How can that be done

Posted: Jan 29, 2010 06:44 PM

View 2 Replies!   View Related
AJAX :: Setting Focus On 2.psotback With Ajax And Usercontrols?
I have a problem setting focus on a usercontrol in asp.

I have a masterpage with a script manager and a few contentpages. On two of the contentpagesI have a usercontrol. Inside this control I have a updatepanel that has another usercontrol that has a asp:textbox, aka TheTextBox. I need those pages to set the focus to TheTextBox.

The innermost usercontrol sets focus in page_prerender: ScriptManager.GetCurrent(Page).SetFocus(TheTextBox);

Now this works on the first pageload, and the second. But not on the third load! And i cant really understad why, but I'm guessing that its because the 2nd postback is renderd inside an updatepanel and somehow that cause the setfocus to not trigger propperly after the 2nd postback.

Posted: Aug 13, 2010 11:11 AM

View 1 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved