TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gopal Ji Singh
NA
39
31.7k
Url Routing in asp.net
May 22 2014 6:03 AM
Hi Dear All
There is a problem which i am facing the problem is my url Routing code is not working This is my first time practice so please help me.
My Global.asax code is
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System" %>
<script RunAt="server">
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
public static void RegisterRoutes(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("RouteForCustomer", "searchresult/{location}/{builder}/{pname}", "~/searchresult.aspx");
}
</script>
And My searchresult.aspx.cs Code is
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Datalayer;
public partial class searchresult : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
public string location, builder, project;
public string myloction, mybuilder, myproject;
protected void Page_Load(object sender, EventArgs e)
{
location = Request.QueryString["location"].ToString();
myloction = location.Replace("---Select---", "");
builder = Request.QueryString["builder"].ToString();
mybuilder = builder.Replace("---Select---", "");
project = Request.QueryString["pname"].ToString();
myproject = project.Replace("---Select---", "");
if (!IsPostBack)
{
getallrecords();
}
//string id = Page.RouteData.Values["location"].ToString();
//string build = Page.RouteData.Values["builder"].ToString();
//string pname = Page.RouteData.Values["pname"].ToString();
//Response.Write("<h1>Customer Details page</h1>");
// Response.Write(string.Format("Displaying information for customer : {0}", id));
}
My Current url is
http://localhost:28654/costodianinfra/searchresult.aspx?location=Lucknow&builder=DLF&pname=My%20pad
and i want url like this
http://localhost:28654/costodianinfra/searchresult/location/Lucknow/
builder/
DLF/
pname/
Mypad
so please help me
Thanx
Gopal
Reply
Answers (
4
)
Update Gridview
Which is the best event to bind a gridview