Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

updatepanel and text box set focus

Posted on 2009-04-13
7
Medium Priority
?
1,043 Views
Last Modified: 2012-06-22
Hi Expert,

I used a updatepanel,  inside this panel, I have two radio buttons and two regular panels, when I click on radio button1, I want panel one to show and inside panel one I want set focus on txtFirstName, I write code to do it, but it do not work, How to make it works?

code fragment are here

Protected Sub rdType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdType.SelectedIndexChanged
        If (rdType.SelectedItem.Value = "new") Then
            Me.Panelone.Visible = true
            Me.txtfirstName.Focus()

thanks in advance
0
Comment
Question by:dshi15
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24135694
Hi dshi15,
I've tested the code that mentioned, it's working fine under my test case. Please post the design code here in case it not match yours.
Check my tested code here:
aspx
============
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
            <asp:RadioButtonList ID="rdType" runat=server AutoPostBack="True">
                <asp:ListItem Value="new">Option 1</asp:ListItem> 
                <asp:ListItem Value="old">Option 2</asp:ListItem> 
            </asp:RadioButtonList> 
            <asp:Panel ID="Panelone" runat=server Visible=false>Panel one<asp:TextBox ID="txtfirstName" runat=server></asp:TextBox></asp:Panel> 
            <asp:Panel ID="Paneltwo" runat=server Visible=false>Panel two<asp:TextBox ID="txt1" runat=server></asp:TextBox></asp:Panel> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">
              </asp:ScriptManager>
          </ContentTemplate> 
        </asp:UpdatePanel>
          
    </div>
    </form>
</body>
 
code-behind
============
Protected Sub rdType_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles rdType.SelectedIndexChanged
        If (rdType.SelectedItem.Value = "new") Then
            Me.Panelone.Visible = True
            Me.txtfirstName.Focus()
        End If
    End Sub

Open in new window

0
 
LVL 1

Author Comment

by:dshi15
ID: 24137353
thanks, I will test code and let you know.
0
 
LVL 1

Author Comment

by:dshi15
ID: 24137575
I tested code, panel one is show and txtfirstname box is show but cursor not jump inside the box.

<body>
    <form id="form1" runat="server">
   
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
              </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
            <asp:RadioButtonList ID="rdType" runat="server" AutoPostBack="True">
                <asp:ListItem Value="new">Option 1</asp:ListItem>
                <asp:ListItem Value="old">Option 2</asp:ListItem>
            </asp:RadioButtonList>
            <asp:Panel ID="Panelone" runat="server" Visible="false">Panel one<asp:TextBox ID="txtfirstName" runat="server"></asp:TextBox></asp:Panel>
            <asp:Panel ID="Paneltwo" runat="server" Visible="false">Panel two<asp:TextBox ID="txt1" runat="server"></asp:TextBox></asp:Panel>
       
          </ContentTemplate>
        </asp:UpdatePanel>
         
   
    </div>
    </form>
</body>


Protected Sub rdType_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles rdType.SelectedIndexChanged
        If (rdType.SelectedItem.Value = "new") Then
            Me.Panelone.Visible = True
            Me.txtfirstName.Focus()
        End If
    End Sub
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 1

Author Comment

by:dshi15
ID: 24137611
I need to mention I have several text box in panel one and I let cursor set in txtfirstname box, so client can fill information.
0
 
LVL 1

Author Comment

by:dshi15
ID: 24137654
If i comment on updatepanel, it works fine. I used IE7.

<body>
    <form id="form1" runat="server">
   
    <div>
    <%--<asp:ScriptManager ID="ScriptManager1" runat="server">
              </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>--%>
            <asp:RadioButtonList ID="rdType" runat="server" AutoPostBack="True">
                <asp:ListItem Value="new">Option 1</asp:ListItem>
                <asp:ListItem Value="old">Option 2</asp:ListItem>
            </asp:RadioButtonList>
            <asp:Panel ID="Panelone" runat="server" Visible="false">Panel one
            <asp:TextBox ID="txtfirstName" runat="server"></asp:TextBox>
            <asp:TextBox ID="txtlastName" runat="server"></asp:TextBox>
            </asp:Panel>
            <asp:Panel ID="Paneltwo" runat="server" Visible="false">Panel two<asp:TextBox ID="txt1" runat="server"></asp:TextBox></asp:Panel>
       
       <%--   </ContentTemplate>
        </asp:UpdatePanel>--%>
         
   
    </div>
    </form>
</body>
0
 
LVL 1

Accepted Solution

by:
dshi15 earned 0 total points
ID: 24137808
I found solution online. Thanks.

Me.ScriptManager1.SetFocus(txtfirstName)
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 24144347
Hi dshi15,
Ok, perhaps your design code is more complicated. I'm glad to hear you find your preferred solution and you may request admin to make this PAQ with points refund.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question