English 中文(简体)
除一定数目的幼年幼年幼年幼年幼年幼年学校外,还有一定数目的幼年幼年学校。 净额,C#
原标题:save a certain number into session on href in ASP.Net, C#
问题回答

Session.Add("egSession", 1) will add 1 to the session cookie egSession.

也许,你也可以肯定,这样做已经存在:

Session.Remove("egSession");
Session.Add("egSession", 1);

To get the querystring value from the address you would (code behind do)

var value = Request["egSession"];

因此,你可以:

Session.Remove("egSession");
Session.Add("egSession", Request["egSession"]);

希望帮助!

** UPDATE **

如果你能够查阅文件,你可以在文件夹中这样做,在<代码>和>上填写你的代码;% ......代码在此......%和>;。

如果知道新届会的可变价值,例如,在你的抽样环境下,可以在任何地方进行。

<% Session["egSession"]=1; %>

如果你想把它作为问答参数予以通过的话:

..../home.aspx?egSession=<%=Session["egSession"]%>

问题在于,你们需要一个价值的名称,即: 比如说,但你可以说你想要什么。

然而,如果你们已经知道你可以做些什么:

..../home.aspx?egSession=1

根据我的理解,你希望这样做:

<><>>>>>

<a href="..../home.aspx?egSession=1">Take Me home</a>

Home.aspx.cs: The Code after page, in such as the OnPageLoad Activities

Session["egSession"] = Request.QueryString["egSession"];

Home.aspx

<div>Session: <% =Session["egSession"] %></div>
<div>Query String: <% = Request.QueryString["egSession"] %></div>

如果你在其中试图做到这一切,我将尝试如下:

APage.aspx.cs

建立公共方法(必要时改变投入参数的类型)

public string SessionMagic(object input)
{
     Session["egSession"] = input;
     return Session["egSession"].ToString();
}

APage.aspx

<a href="..../home.aspx?egSession=<%= SessionMagic(1)%>">A Link</a>

* 。 UPDATE: *

If you can not update the .cs files you can add server side code in the aspx page, not great practice but it can be done. Encapsulate the code in script tags with the run a server attribute set. E.g.:

<script runat="server">
  public string ServerSideFunction(string input)
  {
     Session["egSession"] = Request.QueryString["egSession"];

     public string SessionMagic(object input)
     {
         Session["egSession"] = input;
         return Session["egSession"].ToString();
     }

  }
</script>

你们可以使用 j子,储存你们想要投入会议的价值。

eg:- url- url.apsx/egValue=1 read this url using javascript. Put the key and value into cookie. Then you can read cookie value from server and put it into session.

hope it helps.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签