Click here to Skip to main content
15,918,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,i am implementing url routing in my application.it work fine
eg:WebSite1/users/Randeep

i want work with user id of randeep,it give me user name.

my code is:
Gloabal.asax
C#
void Application_Start(object sender, EventArgs e)
    {
       RegisterRoutes(RouteTable.Routes);

    }
    public static void RegisterRoutes(RouteCollection routes)
    {
       tes.MapPageRoute("kk", "User/{uname}", "~/default2.aspx");
    }


in the first page
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
   {
       string Url = Page.GetRouteUrl("kk", new { uname= (DropDownList1.SelectedItem.Text;) });
       Response.Redirect(Url);
   }


in default2.aspx
C#
protected void Page_Load(object sender, EventArgs e)
   {
       string name = Page.RouteData.Values["uname"].ToString();
       Int32 uid=?
   }

how to pass uname,uid display only name and access uid?
Posted

1 solution

Quote:
String LocationName = SelectDestination.Value;
String Category;
Response.Redirect("Search Result.aspx?Location=" + LocationName + "&Category=" + Category);

Using the Above send the value and using the following code fetch the value.

Location = Request.QueryString["Location"].ToString();
Category = Request.QueryString["Category"].ToString();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900