Last post Nov 14, 2018 03:43 PM by mgebhard
Nov 14, 2018 03:31 PM|Billson3000|LINK
I have a radio button list. Its a simple Yes/No.
When the user clicks "No" then a hidden panel appears with a textbox to add additional information. When they click "No" then nothing additional happens. The problem I have is that when the click "Yes" then the AutoPostback occurs and sets the focus to the
top of my web page. I want the focus to stay on the radio button.
I work out how to do this and have googled for a few hours without success. I would really appreciate any guidance on this please! Thanks very much in advance.
My code is below:
<asp:RadioButtonList ID="rdbList1" runat="server" AutoPostBack="True" RepeatDirection="Horizontal" Width="30%" OnTextChanged="rdbList1_TextChanged">
And code behind:
string focus = Convert.ToString(rdbList1.Text);
if (focus == "Yes")
Nov 14, 2018 03:42 PM|Billson3000|LINK
Sorry experts. After 3 hours of fiddling I cracked it and set the focus elsewhere.
string str = Convert.ToString(rdbList1.Text);
if (str == "Yes")
Panel5.Visible = true;
Nov 14, 2018 03:43 PM|mgebhard|LINK
What does focus on the radio button mean? Do you actually want the page to scroll to the radio button?
If so, try adding MaintainScrollPositionOnPostBack to the page directive.
MaintainScrollPositionOnPostBack = "true"