English 中文(简体)
• 如何在伙伴关系中增加参数。 净额
原标题:How to add parameter to ASP.net page

I have a database of some records of the users of my website, such as Name, Email, Address etc. I have created a page using ASP.net (C#), which can display the information of the user in arranged manner. I want to display that page with information when anyone click the user name from list. How can I add parameter with the page? so that I can fetch data from database using name or ID linked in the list with user name.

我试图做的是:

example.com/userpage.aspx/XYZ
最佳回答

您可以使用彩色参数:

example.com/userpage.aspx?id=XYZ

利用请求标书收集器进入服务器:

string id = Request.QueryString["id"];
问题回答

If you are using classic ASP.NET, then you have to pass parameter to query string as Xander suggest. ASP.NET correctly parses parameters after ? and you can access them via Request["parameterName"].

但是,如果你想要像你所贴出的“用户友好的ur”,那么你就需要有某种机制将用户友好的ur改到系统。

  • First of all, you can use IIS7 Url Rewrite module or any 3d party Url Rewrite module. Usually it is based on regular expressions and can rewrite url /Users/XYZ to /Users.aspx?name=XYZ

  • Also you can use relatively new technology ASP.NET Rounting Engine like Ryan suggested.

  • If your url scheme is complex and you can not describe it with regular expressions, then you may write your own HTTP Module and perform some custom rewrite rules.

如果贵国用户.aspx.cs上页,你可以读到请求书的问答参数,并用它做一些问答(或你打什么进入数据库)。

如果你使用GredView的话,你就只需要把奥托夫Command事件附在会场上,然后点击你可以把你想要在网页上显示的用户信息。





相关问题
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!

热门标签