Trying to set focus to child control inside FormView EditItemTemplate inside a TabPanel

Hey all I have a long page with a bunch of FormViews that I want to have the user click to the EditItemTemplate and have the focus go to that particular FormView in the aspx page. Or if not the focus at least to have the page scroll to where that control is so the user isn't confused

 Here is kind of what I am doing


1    <ajaxToolkit:TabPanel runat="server" ID="Panel1" HeaderText="Account Info">
2    	<ContentTemplate>
3    	<asp:FormView ID="fvMyName" runat="server" DataSourceID="sqlGetMemberName" CssClass="MyFormView">
4    		<EditItemTemplate>
5    			<asp:TextBox Text='<%# Bind("LN") %>' runat='server' ID='tbLN' /><br />
6    			<asp:Button ID="bttnUpdtMemberName" runat="server" Text="Update" CommandName="Update" ValidationGroup="EditMyName" />
7    			<asp:Button ID="bttnCnclMemberName" runat="server" Text="Cancel" CommandName="Cancel" />
8    		</EditItemTemplate>
9    		<ItemTemplate>
10   		<%# Eval("LN") %>
11   		<asp:Button ID="bttnEditMemberName" runat="server" Text="Edit Name" CommandName="Edit" />
12   		</ItemTemplate>
13   	</asp:FormView>
14   	<asp:FormView ID="fvAddress" runat="server" DataSourceID="sqlGetAddress" CssClass="MyFormView">
15   		<EditItemTemplate>
16   			<asp:TextBox Text='<%# Bind("Address1") %>' runat='server' ID='tbAddr1' /><br />
17   			<asp:Button ID="bttnUpdtAddress" runat="server" Text="Update" CommandName="Update" ValidationGroup="EditAddress" />
18   			<asp:Button ID="bttnCnclAddress" runat="server" Text="Cancel" CommandName="Cancel" />
19   		</EditItemTemplate>
20   		<ItemTemplate>
21   		<%# Eval("Address1") %>
22   		<asp:Button ID="bttnEditAddress" runat="server" Text="Edit Address" CommandName="Edit" />
23   		</ItemTemplate>
24   	</asp:FormView>
25   	<!-- MANY MORE FormViews -->
26   	</ContentTemplate>
27   </ajaxToolkit:TabPanel>


I need to set the focus when a given FormView is in EditItemTemplate. I have tried everythign I can think of... like this:

1        protected void fvAddress_PreRender(object sender, EventArgs e) //This version I was trying to target a specific control withing the FormView
2        {
3            if (this.fvAddress.CurrentMode == FormViewMode.Edit)
4            {
5                TextBox box = fvAddress.FindControl("tbAddr1") as TextBox;
6                ScriptManager.GetCurrent(this.Page).SetFocus(box);
7                //ctl00_cntMainBody_Tabs_Panel2_fvAddress_tbAddr1
8            }
9        }

 and sticking this in the OnPreRender of the FormView, but nothing happens. I have tried about 8 quadrillion variations over 3 days and I am about to eat silicone and copper for dinner :o


9/28/2008 11:56:38 PM 17816 articles. 1 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 36
Get it on Google Play
Get it on Apple App Store

bump anyone?

9/29/2008 11:07:22 PM

Similar Artilces:

Controls inside formview inside formview
Hello, I'm trying to insert data into a label that is located in a formview which is located in a formview.  This is what I got so far: Private Sub Test()    Dim fvSecondView As New FormView    fvSecondView = Me.FormView1.FindControl("SecondView")    Dim lblData As New Label    lblData = fvSecondView.FindControl("DataLabel")    lblData.Text = "Some Data" End Sub Now this does work to get data out if I change the last line to: testlabel.text = lblData.Text But just can't seem to get the data to go ...

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.       <script type="text/javascript">        function RegisteredUser1_TabCliked(sender, e) {            var UserName_Control =  $get('<%=UserName1.ClientID%>');             UserName_Control.focus();        } &n...

FileUpload control inside UpdatePanel inside user control inside popup
Hi,     The Asp.Net File Upload control is not working inside update panel. Acutally i have put the FileUpload control inside User Control again inside update panel. Since the update panel does async postback. The posted file is null in the server side. When i do full page level post back it works. but i have to put it inside update panel. How to do it? Becuase the FileUpload control should be in Ajax Model Popup Extender where i have to put update panel to avoid closing of popup after fullpostback. Since the ajax model popup extender is getting closed after full post b...

Set the property of a server control inside a user control inside a Master Page
How do you set the property(ForeColor) of a server control(lnkInquiryReport2) located in a user control (LeftNavMain1) within a Master Page (default.master)? On the user control, expose a property of type color and bind this to the forecolor for the hyperlink control [keep some default value]. On your master page expose the user control as a property. On your content page, access the uc via the master's prop and the forecolor prop via the uc's prop and set it. Instead of exposing the uc from the master, you can also find the uc on the master - cast it to the correct type and then access th...

How to set focus in a control inside Collapsible Panel Control
I am using Collapsible panel Control and inside Contentpanel I have a textbox into which I want to set the focus.  ScriptManager.SetFocus(Textbox1) does not work   Could someone help please?   Thanks, Rupen I found that there is some patch available to fix this issue.  But I do not know how to apply this. Could someone tell me?     Hi Rupen, From the url provided above, I have found a sample with the name " " under "F...

Finding a controls inside a FormView which is inside a MasterPage
Hi, I have few controls (textboxes) inside a FormView that is inside a MasterPage. The findcontrol doesn't work for me or I'm not doing it right. If I JUST use the FormView or JUST the MasterPage then the findcontrol works. For example TextBox idTextBox = (TextBox)FormView1.FindControl("TextBox1"); works if I don't use the MasterPage. Can someone please help? How do you find a control inside the FormView1 that is inside the MasterPage? Any help would be appreciated. Hi, friend:   Try this:         FormViewRow fr = ((FormView)Master.FindCont...

Formview inside Wizard which is inside FormView
Hi, I have a FormView which contains a Wizard which contains some databinding controls in its steps like Gridview,FormView,...and their ObjectDataSource controls I want these controls to perform their insert,update methods only when the Wizard finish button is clicked.Is this possible?  About putting the whole wizard inside a FormView I did this to be able to use Bind+Eval but it is the first time Iam using the wizard control. Hi TheEagle , Try something like this :   protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) ...

Set Focus to a control inside a panel with scrollbars while the control is not in the visible area of the panel
Hello, I have a little problem setting the focus to a control. On my page there is a panel with auto scrollbars. Inside these panel I place Controls, which I add dynamicaly on page load event . After adding several controls to the panel I have to set the focus to a special control I placed on the panel. That is no problem until the auto Scrollbars kick in and the control I have to set the focus to is gets out of the visible area of the panel. Can anyone tell me please how to move the scrollbars of the panel by code or how to set the focus to my control   Thanks   RITC Just ...

How do I control parameter a control that is inside a formview that has another formview in it?
I have a formview2 within another formview1 but I want to control parameter from a sqlDataSource3 outside the formview a control that is in formview2<asp:SqlDataSource ID="SqlDataSource1" SelectCommand='SELECT "USER,UID" FROM "TUSERS"'><asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">    <ItemTemplate>        <asp:Label ID="Label1" runat="server" Text='<%# Bind("USER") %>'></asp:La...

Accessing child controls inside of a GridView inside of a MultiView
I have a fileupload control which is in a itemtemplate field within the GridView: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="Trk_SqlDataSource">                                <Columns>                                 ...

How to take controls inside a .ascx inside the edititemtemplate of a datalist
I've read a lot of posts but I've not found the solution. I want to take controls inside a .ascx that is located  inside the edititemtemplate of a datalist updater.ascx file <table width="100%">     <tr>         <td class="encabezado" colspan="2">             Modifica la noticia</td>     </tr>     <tr>         <td width="25%">       ...

Set Focus inside datalist control
Hi all Guys how can i set focus of a textbox which is render inside a datalist control.   i did that by using txt.focus(); but after post back focus comes back to same row .i want to make it jump in another row . any suggestion and help how to do this row count  and after post back set the focus to next row textbox   thx Try this. Get the reference of the control inside the datalist by using the findcontrol method. Next set that the default focus. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you You can also try and have some javascript...

Events not firing on custom control inside FormView inside UpdatePanel
Hi all- I have a custom control that I have been using inside a FormView; all its events have been firing properly. Recently I placed the FormView inside an UpdatePanel, and now the events of the control are not firing. I set the AutoPostBack property of the control to True and even turned on AutoEventWireup, but the event doesn't fire.I tried adding the control as a Trigger on the UpdatePanel using this syntax: <asp:AsyncPostBackTrigger ControlID="FormView1:CustomControl1" EventName="SelectionChanged" /> but the event still doesn't fire. Am I doi...

Formview inside a formview controller
Hi all, I'm using a formview(say formview1) controller to insert a records to a table. I take a value from a dropdownlist which i have placed in  the InsertItemTemplete of the formview1. Lets say the dropdownlist has list of towns and I need to add a new town to the list while the user is in the insert template. To do this I have added another formview (say formview2) to inser a new record to the towns table. My problem is my dropdown list is not getting updated just after I have added a new town. But if I start insert operation all over again then I can see the new town. I know t...

Web resources about - Trying to set focus to child control inside FormView EditItemTemplate inside a TabPanel -

Resources last updated: 12/29/2015 3:43:09 PM