How can i add Session value in codebehind. I have tried doing it this way but the session does nt have any 开发者_如何学编程value.
x is string.
td1.InnerHtml = "<a href=\"Search.aspx\" onClick=\"Session['catvalue']=" + x + "\">" + x +</a>
Thank you in advance!
Since you're using ASP.NET, you would be better off with an ASP:Link and calling an ASP.NET code behind function.
In your .aspx
page
<asp:LinkButton ID="myLink" OnClick="myMethod" Text="Click me!" runat="server" />
In your .aspx.cs
page (codebehind)
protected void myMethod(object sender, EventArgs e){
Session['catvalue'] = x; //x is defined somewhere
}
精彩评论