如何使用session和querystring将值从一个页面传递到另一个页面 [英] How to pass value from one page to another witout using session and querystring

查看:68
本文介绍了如何使用session和querystring将值从一个页面传递到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我有人如何在gridview链接按钮上发送多个值点击,点击此链接比使用QueryString打开新页面。现在我们想更改QueryString,我不想使用Session,有没有其他方法可以用c#来解决这个问题.asp.net。 gridview linkbutton的吹码。



我的尝试:



Please tell me someone how i can send multiple value on gridview link button click, on click on this link than open new page using QueryString. now we would like to change QueryString and i don't want to use Session, is there any other way to resolve this issue.asp.net with c#. blow code of gridview linkbutton.

What I have tried:

<a href='ActWiseCLG.aspx?DistrictIdCLG=<%# Eval("DistCode")%>&District=<%# Eval("District")%>&dCLG=true'><%# Eval("NoOfCLG")%></a>

推荐答案

如何:在视图状态中保存值 [ ^ ]



如何:从视图状态读取值 [ ^ ]


为什么不想使用Session?这是您的问题的最佳解决方案,我假设是从用户隐藏代码并阻止他们更改它。会话的唯一其他替代方法仍然允许用户查看或更改代码。会话中的数据保留在服务器上,用户永远不会看到它。下一个最佳解决方案是cookie,但您可能需要加密cookie中的数据。使用会话时很麻烦。
Why don't you want to use the Session? It's the best solution for your problem, which I assume is to "hide" the code from the user and stop them changing it. The only other alternatives to the Session still allow the user to see or change the code. Data in the Session stays on the server and the user never sees it. The next best solution would be cookies, but you would probably have to encrypt the data in the cookie. It's a lot of hassle when using the session is simple.


当您将信息从一个页面传递到另一个页面时,您正在执行所谓的维护状态。为了使您的应用程序能够维护该状态,您必须将数据保存在某个地方,无论是在Session中还是在某个地方的后备数据库中。



网站本地无状态且无连接。这是一个查询/响应系统。客户端(浏览器)说嘿,给我这个页面,你的服务器(网络应用程序)会响应该页面或错误页面(如果它不存在)。两台机器之间没有进一步的连接。



因此,您的客户端代码必须传回服务器创建下一页或服务器所需的任何值必须在后台商店中维护这些信息,比如会话或数据库。



...在这里你试图不使用任何框架那样做是否可以帮助你做到这一点!
When you pass information from one page to another you are doing what's called "maintaining state". In order for your application to maintain that state you have to save the data somewhere, either in Session or in a backing database somewhere.

Web sites are natively stateless and connectionless. It's a query/response system. The client (browser) says "hey, give me this page" and your server (web app) responds with that page or an error page if it doesn't exist. There is no further connection between the two machines.

So either your client-side code has to pass back any values the server needs to create the next page or your server has to maintain that information in a backing store, like Session or a database.

...and here you are trying to do it without using any of the framework that is there to help you do that very thing!


这篇关于如何使用session和querystring将值从一个页面传递到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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