to set focus to a control which is in a panel in asp.net 2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • priravi
    New Member
    • May 2007
    • 11

    to set focus to a control which is in a panel in asp.net 2.0

    Hi

    I'm new to this asp.net environment .. i have aproblem like i have a asp page with multiple panel ... the page's default focus is already set to a text box in a panel... now when i click a button in say panel 1 . a model popup panel gets loaded ... now i have to set the focus to the control in that model pop up panel..
    i'm not sure how to do it... can anyonehelp me in this regard .. thanks in advance
  • swifty
    New Member
    • May 2007
    • 1

    #2
    Hi,
    I'm also new to ASP.NET 2.0 and had a simular problem.
    I had a focus on my desired textbox but since I moved that textbox inside a panel + and moved tat panel in an AJAX UpdatePanel I loose the focus.
    When the page loads you can see for 0,5 seconds the cursor in the textbox and than it goes simply away.
    First I thought it had to do with the complicated loading mechanisme of AJAX but when I moved the textbox out of the panels there was no problem.
    Can Some help me?

    Comment

    • bujjai
      New Member
      • May 2007
      • 8

      #3
      Originally posted by priravi
      Hi

      I'm new to this asp.net environment .. i have aproblem like i have a asp page with multiple panel ... the page's default focus is already set to a text box in a panel... now when i click a button in say panel 1 . a model popup panel gets loaded ... now i have to set the focus to the control in that model pop up panel..
      i'm not sure how to do it... can anyonehelp me in this regard .. thanks in advance
      if it is textbox putlike this ....

      txt_box1.Focus( ); particular panel ok...
      i think it works based on my understand.. if not send me i will do and try

      Comment

      • Abdul Haque
        New Member
        • May 2007
        • 17

        #4
        try this on page load

        onload="javascr ipt:document.Fo rmName.txtBoxId .focus();"

        Comment

        • cnotsharp
          New Member
          • Apr 2007
          • 3

          #5
          Setting the focus on page/form load is not a solution.

          Use the proxylink for the ModalPopupexten der and use another link button to show/hide the panel.

          <asp:LinkButt on ID="AddUserLink " runat="server" OnClick="AddUse rLink_Click">[Search Active Directory]</asp:LinkButton>
          <asp:LinkButt on ID="AddUserLink Proxy" runat="server"> </asp:LinkButton>
          <%--<asp:LinkButt on ID="PreviewLink Button" runat="server" CausesValidatio n="true" OnClientClick=" PopUp('CodeSetM aintenance.aspx ');" >LinkButton</asp:LinkButton>--%>
          <asp:LinkButt on ID="PreviewLink Button" runat="server" CausesValidatio n="true" OnClientClick=" PopUp('CodeSetM aintenance.aspx ');" ></asp:LinkButton>
          <ajax:ModalPopu pExtender runat="server" ID="FindUserPop up" BackgroundCssCl ass="modalBackg round" TargetControlID ="AddUserLinkPr oxy" PopupControlID= "FindUserPa nel" CancelControlID ="FindUserClose Button"></ajax:ModalPopup Extender>


          <asp:Panel runat="server" ID="FindUserPan el" CssClass="Modal Window" DefaultButton=" FindUserButton" >
          <table>
          <tr>
          <td class="FieldCap tion">Name:</td>
          <td class="Spacer"> &nbsp;</td>
          <td class="FieldVal ue">
          <asp:TextBox runat="server" ID="FindUserNam eText"></asp:TextBox>
          <asp:Button runat="server" ID="FindUserBut ton" Text="Find" OnClick="FindUs erButton_OnClic k" />

          </td>
          </tr>

          </table>
          </asp:Panel>

          in the code behind

          protected void AddUserLink_Cli ck(object sender, EventArgs e)
          {
          FindUserNameTex t.Focus();
          FindUserPopup.S how();

          }

          post if you anyone of you found any simple solution.

          Comment

          Working...