Javascript和会话变量

编程入门 行业动态 更新时间:2024-10-26 16:30:10
本文介绍了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和会话变量

本文发布于:2023-07-13 03:12:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1099762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!