Click here to Skip to main content
15,886,872 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,
I am facing a problem .I have text box on my page.which have HTML Editor Extender. My text box is inside Update Panel. I have radio button and drop down list also on my page. now problem is that when i Select some thing from drop down or from radio button the focus automatically set on that text box while i set focus on Button on Selected Change. How i Solve This.

Thanks In Advance.

Here Is My Code
C#
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
<table><tr class="TR1">           
                <td width="20%" style="border: 2px ridge #000000">
                    Impact Categories</td>
                <td colspan="3" style="width: 60%" >
                    <table class="style1" style="border: 2px ridge #000000">
                        <tr>
                            <td width="63%">
                                <asp:DropDownList ID="ddl_ImpCat" runat="server" Width="98%" 
                                    AutoPostBack="True" onselectedindexchanged="ddl_ImpCat1_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>   
                            <td width="37%"></td>                        
                        </tr>
                        <tr style="height:120px; text-align: left;" >
                            <td colspan="2" >
                                <asp:TextBox ID="txt_ImpCat" runat="server" Rows="5" TextMode="MultiLine" 
                                    Width="98%"  ></asp:TextBox>
                                <asp:HtmlEditorExtender ID="txt_ImpCat_HtmlEditorExtender" runat="server" 
                                    Enabled="True" TargetControlID="txt_ImpCat"  >
                                    <Toolbar ><asp:InsertOrderedList /> </Toolbar>
                                </asp:HtmlEditorExtender>
                            </td>
                        </tr>
                        <tr>
                        <td colspan="2">
                            <asp:Button ID="btn_impCat" runat="server" Text="Add" 
                                onclick="btn_impCat_Click" /></td>
                        </tr>
                        <tr>
                        <td colspan="2">
                        <asp:GridView ID="grid_impCat" runat="server" Width="100%" 
                                AutoGenerateColumns="False" onrowediting="grid_impCat_RowEditing">
                        <Columns>
                         <asp:TemplateField HeaderText="ID" HeaderStyle-HorizontalAlign="Center"  Visible="false">
                         <ItemTemplate>
                         <asp:Label ID="lbl_CIdd" runat="server" Text='<%#Bind("Id_C") %>' ></asp:Label> 
                         <asp:Label ID="lbl_Count" runat="server" Text='<%#Bind("count") %>' ></asp:Label> 
                         <asp:Label ID="lbl_CatId" runat="server" Text='<%#Bind("Cat_Id") %>' ></asp:Label> 
                        </ItemTemplate>
                       <HeaderStyle HorizontalAlign="Left" Width="5%"></HeaderStyle>
                        </asp:TemplateField>
                         <asp:BoundField DataField="Category" HeaderText="Imapct Category" >
                            <HeaderStyle Width="25%" />
                            </asp:BoundField>
                         <asp:TemplateField HeaderText="Description" HeaderStyle-HorizontalAlign="Center" >
                         <ItemTemplate>
                        <asp:Label ID="lbl_CatDescription" runat="server" Text='<%#Bind("Description") %>' ></asp:Label>           
                        </ItemTemplate>
                      <HeaderStyle HorizontalAlign="Left" Width="60%"></HeaderStyle>   </asp:TemplateField>
                          <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center">
                         <ItemTemplate>
                         <asp:ImageButton ID="imgEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/Images/Edit.gif" Text="Edit" />
                         <asp:Label ID="lbl_edit" runat="server"></asp:Label>
                       </ItemTemplate>   
                        <HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" />
                      </asp:TemplateField>
                        </Columns>
                        </asp:GridView>
                        </td>
                        </tr>
                    </table>
                </td>              
            </tr>
            <tr class="TR3">
                <td width="20%">
                    Life of Mine</td>
                <td colspan="3" style="width: 60%">  
                    <table class="style1">
                        <tr>
                            <td width="20%">
                                <asp:RadioButton ID="rbl_Expl" runat="server" Text="Exploration" 
                                    AutoPostBack="True" oncheckedchanged="rbl_Expl_CheckedChanged" />
                            </td>
                            <td width="20%">
                                <asp:RadioButton ID="rbl_Study" runat="server" Text="Study" AutoPostBack="True" 
                                    oncheckedchanged="rbl_Study_CheckedChanged" />
                            </td>
                            <td width="20%">
                                <asp:RadioButton ID="rbl_Constr" runat="server" Text="Construction" 
                                    AutoPostBack="True" oncheckedchanged="rbl_Constr_CheckedChanged" />
                            </td>
                            <td width="20%">
                                <asp:RadioButton ID="rbl_Oper" runat="server" Text="Operation" 
                                    AutoPostBack="True" oncheckedchanged="rbl_Oper_CheckedChanged" />
                            </td>
                            <td width="20%">
                                <asp:RadioButton ID="rbl_Closure" runat="server" Text="Closure" 
                                    AutoPostBack="True" oncheckedchanged="rbl_Closure_CheckedChanged" />
                            </td>
                        </tr>
                    </table>  
                </td>
            </tr>
            <tr class="TR1">
                <td width="20%" style="border: 2px ridge #000000">
                    Risk Rating(No Control)</td>
                <td colspan="3" style="width: 60%">                          
                    <table class="style1" style="border: 2px ridge #000000">
                        <tr>
                            <td width="50%" align="left">
                                Likelihood</td>
                            <td width="50%" align="left">
                                Severity</td>
                        </tr> 
                        <tr>
                            <td width="50%">
                                <asp:DropDownList ID="ddl_RiskRatLik1" runat="server" Width="90%" 
                                    onselectedindexchanged="ddl_RiskRatLik1_SelectedIndexChanged" 
                                    AutoPostBack="True">
                                </asp:DropDownList>
                                </td>
                            <td width="50%">
                                <asp:DropDownList ID="ddl_RiskRatSev1" runat="server" Width="90%" 
                                    onselectedindexchanged="ddl_RiskRatSev1_SelectedIndexChanged" 
                                    AutoPostBack="True">
                                </asp:DropDownList>
                            </td> 
                        </tr>                         
                        <
                        <tr>
                            <td width="50%" id="tb_Risk1"  runat="server" align="center">
                                            <asp:Label ID="lbl_RiskRatLev1" runat="server" Text="" CssClass="style3"></asp:Label>
                                        </td>
                            <td width="50%" id="tb_Risk11"  runat="server" align="center">
                                            <asp:Label ID="lbl_RiskRatRank1" runat="server" Text="" CssClass="style3"></asp:Label>
                                        </td> 
                        </tr>
                        <tr>
                        <td colspan="2">
                            <asp:Button ID="btn_nocontrl" runat="server" Text="Add" 
                                onclick="btn_nocontrl_Click" /></td>
                        </tr>
                        <tr>
                        <td colspan="2">
                        <asp:GridView ID="Grid_Nocontrol" runat="server" Width="100%" 
                                AutoGenerateColumns="False" onrowediting="Grid_Nocontrol_RowEditing">
                        <Columns>
                         <asp:TemplateField HeaderText="ID" HeaderStyle-HorizontalAlign="Center"  Visible="false">
                         <ItemTemplate>
                         <asp:Label ID="lbl_NCIdd" runat="server" Text='<%#Bind("Id_NC") %>' ></asp:Label> 
                         <asp:Label ID="lbl_NoConrolcount" runat="server" Text='<%#Bind("count") %>' ></asp:Label>
                          <asp:Label ID="lbl_NoConrolLik" runat="server" Text='<%#Bind("LikId") %>' ></asp:Label>    
                            <asp:Label ID="lbl_NoConrolSev" runat="server" Text='<%#Bind("SevId") %>' ></asp:Label>    
                        </ItemTemplate>
                       <HeaderStyle HorizontalAlign="Left" Width="10%"></HeaderStyle>
                        </asp:TemplateField>
                         <asp:BoundField DataField="likelyhood" HeaderText="Likelyhood" >
                            <HeaderStyle Width="30%" />
                            </asp:BoundField>
                         <asp:BoundField DataField="severty" HeaderText="Severity" >
                            <HeaderStyle Width="30%" />
                            </asp:BoundField>
                         <asp:TemplateField>
                        <ItemTemplate>
                        <table id="tbl1"  runat="server" width="100%">
                        <tr>
                        <td  id="tdl1"  runat="server" style="font-weight: bold" align="center" width="50%">
                        <asp:Label ID="lbllevel1" runat="server" Text='<%#Bind("level") %>' ToolTip="Level"></asp:Label> </td>                                             
                       <td  id="tdl11"  runat="server" style="font-weight: bold" align="center" width="50%">
                        <asp:Label ID="lblRank1" ToolTip="Rank" runat="server" Text='<%#Bind("rank") %>'></asp:Label> </td>
                        </tr>
                        </table>                            
                        </ItemTemplate>
                           <
                        <HeaderStyle HorizontalAlign="Left" Width="20%"></HeaderStyle>  
                        </asp:TemplateField>                       
                         <asp:TemplateField HeaderText="Edit" HeaderStyle-HorizontalAlign="Center">
                         <ItemTemplate>
                         <asp:ImageButton ID="imgEdit" runat="server" CausesValidation="False" CommandName="Edit" ImageUrl="~/Images/Edit.gif" Text="Edit" />
                         <asp:Label ID="lbl_edit" runat="server"></asp:Label>
                       </ItemTemplate>   
                        <HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" />
                      </asp:TemplateField>
                        </Columns>
                        </asp:GridView>
                        </td>
                        </tr>
                    </table>                
                </td>
            </tr></table>   </ContentTemplate> </asp:UpdatePanel>
Posted
Updated 22-Jul-14 20:30pm
v5
Comments
Kornfeld Eliyahu Peter 23-Jul-14 2:22am    
Can you show us your relevant code, so we may see the problem?

1 solution

Try adding this script. Mention the button name in getElementById function


XML
<script type="text/javascript" language="javascript">
        window.onload = function () {
            document.getElementById("").focus();
        }
    </script>


OR

You can also set the TabIndex property of the controls.
For more information on TabIndex Property refer the following link:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.tabindex(v=vs.110).aspx[^]
 
Share this answer
 
v2
Comments
ErBhati 23-Jul-14 4:59am    
Hello Prakriti,
I have already set Tabindex.and focus to next control.
Prakriti Goyal 23-Jul-14 5:04am    
Hello,
Have you tried the above javascript code?
Could you pleasae mention the code.
ErBhati 23-Jul-14 5:56am    
Hi,
This is not usefull for me and not related my Question, Becouse i want to focus on next control when one is fill.
Prakriti Goyal 23-Jul-14 6:13am    
Hello,
Please mention on what control do you want the focus.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900