Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 52449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:54:31+00:00 2026-05-10T16:54:31+00:00

I have three TextBox controls on the page <asp:TextBox ID=TextBox1 runat=server AutoPostBack=True OnTextChanged=TextBox_TextChanged TabIndex=1>

  • 0

I have three TextBox controls on the page

<asp:TextBox ID='TextBox1' runat='server' AutoPostBack='True'         OnTextChanged='TextBox_TextChanged' TabIndex='1'> <asp:TextBox ID='TextBox2' runat='server' AutoPostBack='True'         OnTextChanged='TextBox_TextChanged' TabIndex='2'> <asp:TextBox ID='TextBox3' runat='server' AutoPostBack='True'         OnTextChanged='TextBox_TextChanged' TabIndex='3'> 

and an event handler

protected void TextBox_TextChanged(object sender, EventArgs e) {     WebControl changed_control = (WebControl)sender;      var next_controls = from WebControl control in changed_control.Parent.Controls                         where control.TabIndex > changed_control.TabIndex                         orderby control.TabIndex                         select control;      next_controls.DefaultIfEmpty(changed_control).First().Focus(); } 

The meaning of this code is to automatically select TextBox with next TabIndex after page post back (see Little JB’s problem). In reality I receive InvalidCastException because it’s impossible to cast from System.Web.UI.LiteralControl (WebControl.Controls contains actually LiteralControls) to System.Web.UI.WebControls.WebControl.

I am interested is it possible to modify this aproach somehow to receive working solution? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:54:32+00:00Added an answer on May 10, 2026 at 4:54 pm

    OfType

    from control in changed_control   .Parent   .Controls   .OfType<WebControl>() 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page setup like so: <ajax:UpdatePanel id=UpdatePanel1 runat=server UpdateMode=Conditional> <ContentTemplate> <asp:TextBox id=TextBox1
This is the code I have: <body> <form id=form1 runat=server> <div> <asp:TextBox ID=txtInsertComments CssClass=expanding
I have an asp page with some Textbox controls on it. By default, the
I have a Panel on my Page: <asp:Panel ID=pnlTest runat=server /> Then I dynamically
I have a textbox and an image button as follows <asp:TextBox ID=myText runat=server></asp:TextBox> <asp:ImageButton
Lets just say that I have three textboxes: TextBox1, TextBox2, TextBox3. Normally if I
If I put a control in a .aspx file like this; <asp:TextBox ID=protectedTextBox runat=server>Some
How to order Controls at runtime in ASP.NET for instance I have three text
I have a dynamically created TextBox in a C#/ASP.NET web page that I want
In my Summary page, I have two CalendarExtender controls to enable someone to select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.