日期:2014-05-17 浏览次数:20549 次
<%@ Page Language="C#" Debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { } protected void RadioButtonX_CheckedChanged(object sender, EventArgs e) { RadioButton r = sender as RadioButton; if (r.ID == "RadioButton1") { Panel2.Visible = false; Panel1.Visible = true; Page.ClientScript.RegisterStartupScript(Page.GetType(), "js", "scrollTo('" + Panel1.ClientID + "')", true); } else if (r.ID == "RadioButton2") { Panel1.Visible = false; Panel2.Visible = true; Page.ClientScript.RegisterStartupScript(Page.GetType(), "js", "scrollTo('" + Panel2.ClientID + "')", true); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <script type="text/javascript"> function scrollTo(divid) { d = document.getElementById(divid); if (document.documentElement) document.documentElement.scrollTop = d.offsetTop; else document.body.scrollTop = d.offsetTop; } </script> </head> <body> <form id="form1" runat="server"> <asp:RadioButton ID="RadioButton1" AutoPostBack="true" runat="server" GroupName="A" OnCheckedChanged="RadioButtonX_CheckedChanged" /> <asp:RadioButton ID="RadioButton2" AutoPostBack="true" runat="server" GroupName="A" OnCheckedChanged="RadioButtonX_CheckedChanged" /> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <p> x</p> <asp:Panel ID="Panel1" runat="server" Visible="false"> <div style="border: 2px solid red; height: 200px">内容11111111111111</div> </asp:Panel> <asp:Panel ID="Panel2" runat="server" Visible="false"> <div style="border: 2px solid red; height: 200px">内容222222222222</div> </asp:Panel> </form> </body> </html>