ASP.net - Get ID from URL
13,072
Change your code to this:
protected string FormatUrl(int FriendsAccountID) { return "WebForm3.aspx?UserID=" + FriendsAccountID; }
Then you can access the UserID like this:
Request.QueryString["UserID"];
Here is a link to QueryString on MSDN.
Author by
Robert Pallin
Updated on June 04, 2022Comments
-
Robert Pallin almost 2 years
I have a datalist and I'm sending the user ID of the user through the URL to another page:
<asp:HyperLink ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' NavigateUrl='<%# FormatUrl( (int) Eval("FriendsAccountID")) %>' />
and the function:
protected string FormatUrl(int FriendsAccountID) { return "WebForm3.aspx?" + FriendsAccountID; }
This works but I'm kind of a noobie and I'm not sure how get the ID once I'm on the next page. Any ideas?
-
Robert Pallin almost 12 yearsCan that go straight into the page load WebForm3?
-
Christer Berglund almost 12 yearsYes. Every Webform has access to the Request object.