一个页面上有多个radiobutton,某一个被选中时,页面下面将显示隐藏的panel,现在想实现点击radiobutton时,页面跳转到所显示的panel上面,就是将panel在页面中间。
因为页面内容较多,如果没有跳转,只能通过下拉才能看到新显示出来的panel的内容。
因为页面内容较多,如果没有跳转,只能通过下拉才能看到新显示出来的panel的内容。
解决方案 »
- CS文件控制li问题
- 在服务器上导出word出现错误,求解决
- 【初学求教】在 <head> 元素内只能有一个 <title> 元素
- 菜鸟提问
- 在UpdatePanel中使用FileUpload怎么做到不刷新页面?
- FCKeditor图片上传成功后文件夹下面没有
- 关于点击右键生成菜单问题。
- 点击treeview的某个结点,希望可以把值传到另一个页面
- 把Excel文件内数据导入数据库时,如何才能使打开的Excel文件不受版本限制??
- 小弟写了一半的仿照MOP的论坛。希望大家光顾。
- 急急急!!config配置authorization 后,输入正确的用户名和密码也不能登录
- 关于支付成功后用户关闭浏览器怎么办?
<a href="#ct2">跳转到2</a>
<br>
<div id="ct1" style="height:1000px;">1</div>
<div id="ct2">2</div>
protected void Page_Load(object sender, EventArgs e)
{
Page.SmartNavigation = true;
}
试试啊,不行就用脚本吧。
<%@ 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>