session的问题
我做了一个切换城市的用户控件,默认的城市是北京,当我点选中其他的城市时,首页的城市就会变成我选中的那个城市,可其他页面还是北京阿?代码如下:
CS代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["city"] = Literal_City.Text;
}
}
protected void bj_Click(object sender, EventArgs e)
{
Literal_City.Text = "北京";
Session.Add("city", Literal_City.Text);
}
protected void tj_Click(object sender, EventArgs e)
{
Literal_City.Text = "天津";
Session.Add("city", Literal_City.Text);
}
protected void sh_Click(object sender, EventArgs e)
{
Literal_City.Text = "上海";
Session.Add("city", Literal_City.Text);
}
protected void cq_Click(object sender, EventArgs e)
{
Literal_City.Text = "重庆";
Session.Add("city", Literal_City.Text);
}
protected void xa_Click(object sender, EventArgs e)
{
Literal_City.Text = "西安";
Session.Add("city", Literal_City.Text);
}
protected void sjz_Click(object sender, EventArgs e)
{
Literal_City.Text = "石家庄";
Session.Add("city", Literal_City.Text);
}
protected void ty_Click(object sender, EventArgs e)
{
Literal_City.Text = "太原";
Session.Add("city", Literal_City.Text);
}
protected void sy_Click(object sender, EventArgs e)
{
Literal_City.Text = "沈阳";
Session.Add("city", Literal_City.Text);
}
protected void cc_Click(object sender, EventArgs e)
{
Literal_City.Text = "长春";
Session.Add("city", Literal_City.Text);
}
html代码:
<div style="width:357px; float:left; line-height:46px; height: 195px;">
世纪新网 >> 生活分类信息:<span class="hong25"><asp:Literal ID="Literal_City" runat="server" Text="北京"></asp:Literal></span>|<span onmouseover="city.style.display = 'block'" onmouseout="city.style.display='none'">[<a href="#">切换城市</a>]</span>
<div id="city" onmouseout="this.style.display='none'" onmouseover="this.style.display='block'" style="left: 254px; top: 28px">
<asp:LinkButton ID="bj" runat="server" OnClick="bj_Click" >[北京]</asp:LinkButton>
<asp:LinkButton ID="tj" runat="server" OnClick="tj_Click" >[天津]</asp:LinkButton>
<asp:LinkButton ID="sh" runat="server" OnClick="sh_Click" >[上海]</asp:LinkButton>
<asp:LinkButton ID="cq" runat="server" OnClick="cq_Click" >[重庆]</asp:LinkButton>
<asp:LinkButton ID="xa" runat="server" OnClick="xa_Click" >[西安]</asp:LinkButton>
<asp:LinkButton ID="sjz" runat="server" OnClick="sjz_Click" >[石家庄]</asp:LinkButton>
<asp:LinkButton ID="ty" runat="server" OnClick="ty_Click" >[太原]</asp:LinkButton>
<asp:LinkButton ID="sy" runat="server" OnClick="sy_Click" >[沈阳]</asp:LinkButton>
<asp:LinkButton ID="cc" runat="server" OnClick="cc_Click" >[长春]</asp:LinkButton>
</div></div>
大家帮忙解决一下阿!!!谢谢了!!!