i have two textboxes one id and other for name and a listbox for displaying all the names and
5 image buttons add, save, edit , delete and cancel . if i click on add button id is automatically
generated and displayed in id textbox i need to get the focus of cursor to the name text box at the
same time. i give txtname.focus() function but it didnt work . I am using a WebAsyncRefreshPanel in
the page . if i remove it i get the focus on the text box . but i need the refresh panel.pls give me a method
to get focus without removing the webasyunchronous refresh panel.Thanks in advance
I have the same issue, just with an Ultrawebgrid inside a WARP. I want to give the second cell in the webgrid focus after each postback.
On the inital full postback this is easy to do in page_load by using:wgMain.Focus()wgMain.Rows(0).Cells(1).Selected = TruewgMain.Rows(0).Cells(1).Activate()
I thought about using a client-side function on warp refresh complete, but the webgrid CSOM has no focus() method. So how to focus the Ultrawebgrid control on client-side?
Regards,Andreas
Hi,
If I understood your question correctly, then you need to set focus to a particular control/element located in WARP after postback according to a particular action/control which triggered postback.
I suggest to use clientEvents of WARP.On request you may check which element triggered postback and memorize (in global variable) id of element which should get focus after response.On response you may find reference to element which should get focus and call its focus/select member methods.
Below sample will set focus to TextBox1 if Button1 was clicked, and set focus to TextBox2 if Button2 was clicked.
<script type="text/javascript">var idForFocus = null;function WebAsyncRefreshPanel1_RefreshRequest(oPanel,oEvent,id){ idForFocus = null; if(!id) return; if(id.indexOf('Button1') >= 0) idForFocus = '<%=TextBox1.ClientID%>'; if(id.indexOf('Button2') >= 0) idForFocus = '<%=TextBox2.ClientID%>';}
function WebAsyncRefreshPanel1_RefreshComplete(oPanel){ if(!idForFocus) return; var txt = document.getElementById(idForFocus); if(txt) try { txt.select(); txt.focus(); }catch(ex){}}</script><igmisc:WebAsyncRefreshPanel ID="WebAsyncRefreshPanel1" runat="server" RefreshComplete="WebAsyncRefreshPanel1_RefreshComplete" RefreshRequest="WebAsyncRefreshPanel1_RefreshRequest"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Button1" /> <asp:Button ID="Button2" runat="server" Text="Button2" /></igmisc:WebAsyncRefreshPanel>