0

i have an issue , when i click on YES or NO (radio button) to enable/disable DIV section (EmployerInfo), it causes the whole page to refresh and scrolls back to the top of firefox every browser. i set Autopostback to true and i put MaintainScrollPositionOnPostback="True" in page directive but still it cause full post back and scrolls page to the top.

here is my code:

<asp:RadioButton ID="rdobtnEmploymentYes" GroupName="grpEmploymentYesNo" runat="server" Text="Yes" OnCheckedChanged="check_clicked" AutoPostBack="true"   />
<asp:RadioButton ID="rdobtnEmploymentNo" GroupName="grpEmploymentYesNo" runat="server" Text="No" OnCheckedChanged="check_clicked" AutoPostBack="true"  />



in .cs file i wrote this fucntion

protected void check_clicked(object sender, EventArgs e)
    {
        if (rdobtnEmploymentYes.Checked)
        {
            EmploymentInfo.Visible = true;
        }
        else
        {
            EmploymentInfo.Visible = false;
        }

IT ENABLES AND DISABLES THE DIV SECTION ,that's fine BUT CAUSES THE PAGE TO SCROLL UP. WHY ???

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by HunainHafeez
0

If you are only showing or hiding a div element based on the radiobutton, I think it would make more sense for you to use JavaScript. There doesnt seem to be any reason to make a trip back to the server to process that request.

0

yes jorgem, i know but the thing is that why it does so mean why it scrolls to top ? solution plz ?

0

its a post back... you are reloading the page. that is why i suggested a client side approach. so this directive didnt work for you?

<%@ Page MaintainScrollPositionOnPostback="true" %>

hmm...

How about in your web.config. Try this:

--> Web.config <system.web> section <pages maintainScrollPositionOnPostBack="true" />

0

@jorgeM : tried the 2nd solution too. still problem. i mean web.config's solution :(

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.