• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 568
  • Last Modified:

Another way of setting focus?

I have a multiview with a next button. I also have a dropdownlist in one of the views. Everytime user clicks on a dropdownlist item, I call the selectedindex changed and reset the focus on the "next" button. I do it like below..

I want to do this in Javascript and not do a postback..anyway to do this?

This is what i have now:

<asp:MultiView runat="server"  ActiveViewIndex="0" ID="mvOutgoingPatient">
 .....
 <asp:DropDownList runat="server" TabIndex="16" AutoPostBack="true" OnSelectedIndexChanged="ddlAppoitment_SelectedIndexChanged" CssClass="InputFields" ID="ddlDoctor"></asp:DropDownList>
......

</asp:MultiView>

 <div class="stepNext"  style=" height:55px" >
           <asp:Button ID="btnNext" runat="server" CssClass="next" Text="Next &gt;"  OnClick="btnNext_Click" />	
           
         </div>

----------------------- in code behind

 protected void ddlAppoitment_SelectedIndexChanged(object sender, EventArgs e)
    {
        ScriptManager.GetCurrent(this.Page).SetFocus(btnNext);
    }

Open in new window

0
Camillia
Asked:
Camillia
1 Solution
 
Rajar AhmedConsultantCommented:
try this,
<script>
        function setbtnFocus() {
            document.getElementById('<%=btnNext.Clientid %>').focus();
        }
    </script>
<asp:DropDownList runat="server" TabIndex="16"  onchange="setbtnFocus();" CssClass="InputFields" ID="ddlDoctor">
 <asp:ListItem>1</asp:ListItem>
 <asp:ListItem>2</asp:ListItem>
 </asp:DropDownList>

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now