Setting focus on RadioButtonList after postback

T

TheDrifter

This seems to be one of the great mysteries of ASP.NET as I have seen
numerous postings on this with absolutely no answers. SetFocus does not work
on the RadioButtonList control. Does anybody know the proper way to set the
focus on a RBL after a postback so the user at least knows where they are on
the screen? This cannot be so difficult?
 
G

Gaurav Vaish \(a.k.a. MasterGaurav\)

This seems to be one of the great mysteries of ASP.NET as I have seen
numerous postings on this with absolutely no answers. SetFocus does not
work
on the RadioButtonList control. Does anybody know the proper way to set
the

Because RadioButtonList has no parallelism in HTML.
It's only the individual items in RadioButtonList - RadioButton - that
figures in HTML and can be focussed.

What you can do is something as follows:

ListItem selectedItem = radioButtonList.SelectedItem;
selectedItem.Attributes.Add("onload", "this.focus();");


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top