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 ???

Recommended Answers

All 4 Replies

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.

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

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" />

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.