开发者

Dynamic Content ASP.net C#

开发者 https://www.devze.com 2023-02-14 20:33 出处:网络
I have looked everyw开发者_StackOverflow中文版here for a tutorial on this how do I go about making a aspx page that I pass an ID for a item into so the url would be item.aspx?id=1042 and it would disp

I have looked everyw开发者_StackOverflow中文版here for a tutorial on this how do I go about making a aspx page that I pass an ID for a item into so the url would be item.aspx?id=1042 and it would display data from sql database for item #1042. Does anyone have any information on how I do this, any articles or tutorials would be wonderful.


You don't really need a tutorial. Just use the Request.Querystring property like this:

int id = int.Parse(Request.Querystring("id").ToString());

// then use the id int in a db query

Good luck!


You should be looking at ASP.NET AJAX. Basically you send an XMLHttpRequest (AJAX) back to the server with the id parameter, parse it like Paul Sasik said, then query the db and render the response.


if (Request.QueryString.HasKeys())
{
    var values = Request.QueryString.GetValues("id");
    if (values != null)
    {
        var id= Convert.ToInt32(values[0]);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消