开发者

Set Session in codebehind for an Onclick

开发者 https://www.devze.com 2023-03-18 05:54 出处:网络
How can i add Session value in codebehind. I have tried doing it this way but the session does nt have any 开发者_如何学编程value.

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消