开发者

Set Session in codebehind for an Onclick

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜