TextChange event loose focus in asp.net - asp.net

I am trying a very simple thing. I have 3 textboxes and 3 labels. On text change i am setting the content of label.
The issue is when i insert some value in 1st textbox(e.g 50) change the focus to another textbox the values in label is reflected perfectly.
But the focus which i setted on 2nd textbox is lost. And the focus is lost somewhere.
I need to click again on 2nd textbox to get focus.
The same issue is reproduced if TAB is clicked to change focus.
I have made a small demo project for the same and attached. You can avail that from the below link
https://skydrive.live.com/redir?resid=A716D678775EEF95!115&authkey=!ABp6kAon_ZNDLBU
Please someone help me...what am i doing wrong??
Thanks in advance...

This is a rather common issue in ASP.NET, as described here: http://www.codeproject.com/Articles/17571/Maintain-focus-between-postbacks-in-ASP-NET-2-0-al or here: How do I maintain focus position in UpdatePanel after page partial post back. Those links also contain some suggestion on how to solve this issue.
One of the possible solutions is to keep track of control with focus, put information about it into a hidden field and manually restore the focus after postback. This method is described in the first link mentioned.

Related

DropdownList and Textbox not callling SelectedIndex/Text Changed on first postback in IE and FF

I know this is a problem that's been asked a few times before, but having had a look around I can't seem to find an answer that works for me.
I have a VB.NET page with 2 textboxes (set to show dates using JQuery), a dropdownlist and a datagrid.
Both textboxes and the dropdownlist are set to fire events, if they're changed, to update the datagrid.
Generally this works fine with one exception; when I change the value of either the textboxes or the dropdownlist after the initial page loading it often doesn't fire the event, the postback is set to false and the dropdownlist value is cleared; this doesn't happen in Chrome and is less frequent in Firefox than in IE.
I've tried the following:
I've set autopostback=true on all items
Tried adding an extra item, which isn't enabled, to the dropdownlist
Moved the boxes/List outside the update panel
Set ViewStateMode=Enabled
Tried adding a hidden field which is set to Request.Form(ddlDropdownList.UniqueNumber) and comparing it to Request.Form(ddlDropdownList.UniqueNumber) in the page load as a way to fire the event (the suggestion says to use Request.Forms, but this isn't coming up as an option on intellisense?)
All of these solutions either don't work, cause other issues, or I'm not doing them right (Which could certainly be the case)
Thanks in advance for any help you can give.
I don't know if this will help, it's been a while since I've done web forms, but I do recall there being a problem with listboxes where I had to check if the page was not on a postback when populating it.
So basically in your page loading method, check to see if the page is not a postback before initalising it. I found that even though I selected a new item, it was resetting the list back to it's default state.
This may or may not help you, but I thought it was worth at least mentioning it.

How to fill a TextBox in InsertItemTemplate(ListView) with a selected Value from ModalPopup displayed by clicking a Link in the InsertItemTemplate?

I have really put in significant efforts to somehow find an answer; having failed I have then searched many forums before coming to bother the experts here. Please help!
I have a Listview in a USerControl of my main form; its InsertItemTemplate has a TextBox whose value is to be filled in by Clicking a Linkbutton in a Row of another Listview (in another UserControl) in the ModalPopUp Panel, which Pops up when a Linkbutton in the Parent UserControl is Clicked. After the selection (by clicking the LinkButton in the ModalPopUp), the ModalPopup closes immediately and in Code-Behind of the Child-UserControl, I save the Selected-Value in a Session variable. My problem is (Because the InsertItemTemplate is already remaining displayed) I do not know where to put the code for filling the TextBox (in the Parent UserControl) with the saved value from the Session-Variable.
ItemCreated, ItemDataBound are already executed before the ModalPopUp is displayed. So, though I have the required Value of the TextBox in the Session-Variable, I am unable to fill the TextBox in the InsertItemTemplate.
I will appreciate any suggestions, if any of you have found any answers to such a situation. I feel SOMEHOW the InsertItemTemplate should be made to load again and this TextBox in it should be filled in the ItemCreated for the InserItem datatype. But I do not know how to make it happen???
Any thoughts welcome. I have similar logic in many places in my App; and if I can't do it it will significantly affect my app :-(.
Hope one of you experts will kindly help me out. Thanks.
Thanks. I could fix it. Mentioning it here for some newbie (like me) who may face a similar issue.
The question was, where to put the Code (for the Selected Value to fill the TextBox in the InsertItemTemplate) in the scenario described above in the question.
I find that in the Pre-Render Event of the Parent UserControl, in the PostBack mode, after finding the said TextBox Control via the e.InsertItem.FindControl("TextBox"), I am able to fill it with the selected value. I don't know if this is the best way to do it, but it works fine now.
Hope this may be of some help to someone! Thanks.

Focus Jumps to Address

I am working on an ASP.NET 2.0 (VB) web application. I am having trouble controlling tab behavior.
TabIndex is set throughout the form and tabs as expected.
But,after making a change in a textbox and hitting Tab or Enter, the focus jumps to the web address bar instead of the next field.
I have tried:
1.SetFocus on the text change event
2.Saving last field name in a hidden textbox and set focus to saved textbox name on Page Load if Post back
3.SetFocus on Pre_render
Still, focus jumps to browser address bar on tab or enter.
I think it may be losing the tab index on post-back.
Any clues?
Thanks in advance, any help is appreciated
When you have AutoPostBack on a TextBox control with TabIndex assigned it could be a little complex to manipulate the Focus. Check out this tutorial which will show you a little trick to Shift Focus to the next control.
Good luck!

Mulitple Modal Popups not working in IE 7

I have two modal popups on a page, both inside user controls, and both have different names, and different behavior id's. Also, the hidden buttons used with them have different id's. I use javascript to click those buttons to show the popup.
On load of the page, the first popup is hidden, but the second one is not, and is at the bottom of the page completely visible. When I click the link that is supposed to show the second popup, the first one is shown instead, but the javascript to load the default values into the first popup does not run, so I'm confused as to what is going on. Any ideas?
I have solved the issue. My situation is bit different. for you both pop ups are in a user control. But for me only one is in user control and other one is in the page itself. hope this will shed some light on your issue.
I gave different id's for
Hidden Target button (TargetControlID)
OK button (OkControlID)
Popup Panel (pnlPopup)
Model Popup control
Still if you are not sure, try your page in firefox with firebug installed. This will help you to identify any java-script errors.
Hope this helps.

Overriding a radgrid row with a sliding popup when i click on delete option

I have a problem with radGrid Control..
According to my clients requirement we are displaying data in radGrid. But what my problem is, when we click on delete button, the row which has to be delete should be replace with a sliding popup asking " Are u sure you want to delete this row" and with two buttons.
I have tried a lot, but I didn't get any solution for that..
Can any one please help me..
Well, do you have to have a "sliding" popup? In-built it supports a nice radwindow element for the prompt, which you may be able to programmably slide. Set these properties on the gridcommandcolumn: ConfirmTitle="Delete Medical Home" ConfirmDialogType="RadWindow". Otherwise, you can give the button an OnClientClick value that fires a function to show the prompt, and manually control the postback for the delete. For the latter this requires some research, I'm not exactly sure how that works with the RadGrid (the postback to submit the command).
HTH.
Brian

Resources