main.aspx中有两个iframe,
<iframe src="Top.aspx" name="top" ></iframe> //头,导航
<iframe src="GBook.aspx" name="content"></iframe> //内容
在top.aspx中有个linkbutton,单击linkbutton时 框架content中的页面变为GBook.aspx?ID=id其中 id的值为sesson[“userID”]的值意思是获取session,单击linkbutton时隐式提交有知道的朋友麻烦告诉下
<iframe src="Top.aspx" name="top" ></iframe> //头,导航
<iframe src="GBook.aspx" name="content"></iframe> //内容
在top.aspx中有个linkbutton,单击linkbutton时 框架content中的页面变为GBook.aspx?ID=id其中 id的值为sesson[“userID”]的值意思是获取session,单击linkbutton时隐式提交有知道的朋友麻烦告诉下
LinkButton1.Attributes.Add("target", "Content");
LinkButton1.Attributes.Add("href", "WebForm1.aspx?ID="+Session["userID"].ToString());
public static string id;
protected void Page_Load(object sender, EventArgs e)
{
id = Session["userID"].ToString();
}前台是
href="GBook.aspx?ID=<%=id %>" target="content"
这样能实现,我的意思是想在前台获取session 然后隐士提交,看了很多用JS的,但是我用的时候实现不了
protected void LinkButton1_Click(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "js", "window.top.frames[\"content\"].location.href='GBook.aspx?ID=" + Session["userID"].ToString() +"';", true);
}这样就不用在Page_Load中加那两句话了
<a href=''></a>转向
private void XINXI_Click()
{ strID = Request["id"]; LinkButton1.PostBackUrl = "xinxi.aspx?id=" + strID + ""; }
protected void Page_Load(object sender, EventArgs e)
{
XINXI_Click(); }
function GetSession()
{
//先判断其是否存在
if(String(<%=Session["UserID"] %>)=="")
{
alert("不存在该Session值");
return;
}
else
{
alert(<%=Session["UserID"] %>);
}
}
</script>
protected void LinkButton1_Click(object sender, EventArgs e)
{ XINXI_Click(); }
首先应在Top.aspx 的页面加载事件中为LinkButton1添加客户端属性或事件
string id=Session["userId"].ToString();
LinkButton1.Attributes.Add("target", "Content");
LinkButton1.Attributes.Add("href", "WebForm1.aspx?id="+id);
target 属性是在iframe框架中定义在一个子框架中链接反映页面在另一个页面中