Javascript和会话变量 [英] Javascript and session variables

查看:89
本文介绍了Javascript和会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储事件的数据库和一个带有日历对象的页面。渲染天数时,它会查看月份事件,如果有任何匹配,则会在当天渲染,它会创建一个链接按钮来表示日历中当天的事件并将其添加到该单元格。我在linkbutton中添加了一些javascript来将window.location更改为一个页面,以查看在查询字符串中传递EventID的事件详细信息(我尝试设置新创建的链接按钮的postbackurl,但它没有导致回发...没有运气)。我需要设置一个Session变量ie。会话(EditMode)=编辑因此新页面将知道它是获取现有的事件信息而不是准备创建新事件?任何建议?

I have a database that stores events in it and a page with a calendar object on it. When rendering the days it looks through the months events and if any match the current day being rendered it creates a linkbutton to represent the event in the day on the calendar and adds it to that cell. I add some javascript to the linkbutton to change the window.location to a page to view event details passing EventID in the querystring ( I tried setting the postbackurl of the newly created linkbutton but it wasnt causing a postback... no luck). I need to set a Session variable ie. Session("EditMode") = "Edit" So the new page will know it is to get an existing event info rather than prepare to create a new event? Any SUGGESTIONS?

推荐答案

您的会话变量由服务器控制,
JS运行客户端,因此不能直接修改变量。

Your session vars are controlled by the server, JS runs client side, and as such cannot modify the vars directly.

您需要使用POST或GET和隐藏的
iframe或XMLHTTPRequest()调用来发送服务器请求以从JS发送数据
服务器,然后让你的服务器端代码处理变量。

You need to make server requests using POST or GET and hidden iframes, or XMLHTTPRequest() calls to send data from the JS to the server, and then have your server side code handle the vars.

添加另一个查询字符串变量,页面可用于触发现有vs新。

Add another query string variable that the page can use to trigger existing vs new.

这篇关于Javascript和会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆