Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

routing url error

$
0
0

i wrote this code in view userPage.aspx after registering map routes

"routes.MapPageRoute("Users", "user/{Id}", "~/viewuser.aspx", true, new RouteValueDictionary {{"user","0"}});"

int id;
            if (int.TryParse(Page.RouteData.Values["Id"].ToString(), out id) == true)
            {
                Adapter = new SqlDataAdapter("SELECT Title, Context, PhotoPath, Date, Time, Status, UserId, AgeId, CId, SubjectTypeId FROM Subjects WHERE SubjectId='" + id + "'", con);
                Adapter.Fill(ds, "Topic");
                if (ds.Tables["Topic"].Rows.Count > 0)
                {
                    string text = getUserName(int.Parse(ds.Tables["Topic"].Rows[0].ItemArray[0].ToString()));
                    HyperLink1.Text = text;
                    string url = "~/user/" + ds.Tables["Topic"].Rows[0].ItemArray[6].ToString();
                    HyperLink1.NavigateUrl = url;
                    CID.Text = getClassification(int.Parse(ds.Tables["Topic"].Rows[0].ItemArray[8].ToString()));
                    date.Text = ds.Tables["Topic"].Rows[0].ItemArray[3].ToString();
                    time.Text = ds.Tables["Topic"].Rows[0].ItemArray[4].ToString();
                    agePeriod.Text = getAgePeriod(int.Parse(ds.Tables["Topic"].Rows[0].ItemArray[7].ToString()));
                    membership.Text = getMembership(int.Parse(ds.Tables["Topic"].Rows[0].ItemArray[6].ToString()));
                    title.Text = ds.Tables["Topic"].Rows[0].ItemArray[0].ToString();
                    Subject.Text = ds.Tables["Topic"].Rows[0].ItemArray[1].ToString();
                    if (ds.Tables["Topic"].Rows[0].ItemArray[2].ToString() != "")
                    {

                    }
                    else
                    {
                        Image1.Visible = false;
                    }
                }
                else
                {
                    title.Text = "لا يوجد موضوع لعرضه";
                }
            }





null execption keeps thrown, i do not know how to debug because the new url must be ~/user/10 and on page load, page url is ~/viewuser.aspx, how to set url after routing in pageload event ? how can i set id value befor page loading to be able to debug ? or any other suggested solution ?

thanks


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>