如何在多页asp.net中处理querystring [英] how to handle querystring in Multiple pages asp.net

查看:61
本文介绍了如何在多页asp.net中处理querystring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是

如何在多个页面中处理查询字符串asp.net

mydemo.com \ home.aspx?id = 1
mydemo.com \ contact-us.aspx?id = 1
mydemo.com \ projects.aspx?id = 1


并且此ID值是动态的...

my requirement is that

how to handle querystring in Multiple pages asp.net

mydemo.com\home.aspx?id=1
mydemo.com\contact-us.aspx?id=1
mydemo.com\projects.aspx?id=1


and This ID Values is dynamic ...

推荐答案

处理一页的查询字符串对于任何页面都是相同的.

QueryString是一种页面级状态管理技术.进入特定页面后,您可以使用Request.QueryString
访问查询字符串
在此处了解有关查询字符串的信息:使用QueryString在页面之间传递变量 [
Handling querystring for one page is same for any page.

QueryString is a page level state management technique. Once you are on a particular page, you can access the query string using Request.QueryString

Read about querystring here: Passing variables between pages using QueryString[^]


每页,您需要编写代码来处理该页面的查询字符串.实际上,每个页面都是在请求期间进行编译和创建的,其他页面甚至不存在于内存中.您可以创建基本页面类,以某种方式以某种方式插入查询字符串值,还可以创建静态字符串类以强烈键入查询字符串值(在本例中为id),但是每个页面都将负责响应查询字符串以与其控件互动的方式.集中处理值的唯一另一种方法是使用母版页.

另外,您还没有告诉我们该查询字符串值的作用.
Each page, you need to write the code to handle the query string for that page. In fact, each page gets compiled and created during a request, the other pages do not even exist in memory. You CAN create a base page class that somehow interpets a query string value the same way, and you can also create a static string class to strongly type the query string value ( id in this case ), but each page will be responsible for responding to the query string in a way that interacts with it''s controls. The only other way to centralise dealing with the value, is using a master page that does so.

Also, you have not told us what this query string value even does.


我认为您想传递不同页面的查询字符串参数,然后传递其页面类型并检查该ID是否为请求页面中的特定页面.您还可以使用 eval("EmpId")函数为链接绑定ID.

谢谢
纳恩·查瓦达(Nayan Chavada)
I think you want to pass query string parameter for different pages then pass page type with it and check for that id for the specific page in the requested page. you can also use eval("EmpId") function to bind id for the link.

Thanks
Nayan Chavada


这篇关于如何在多页asp.net中处理querystring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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