Virtual directory and NavigateUrl

Topics: User Forum
May 26, 2008 at 5:50 AM
I have a strange issue with HyperLink.NavigateUrl.

If I create my PageMethod call in Page_Load, it includes the virtual folder. But if I create it somewhere else, like in RowDataBound of a GridView, it does not, so the URL fails to redirect to the correct location.

For example, using url aliasing, this:


protected override void OnLoad(EventArgs e)








    this.requesttHyperLink.NavigateUrl = PageMethods.RequestEdit.EditRequest(108231);



produces this url:


but this:


protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e)




    if (e.Row.RowType == DataControlRowType.DataRow)




        int requestNumber = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "RequestNumber"));



        HyperLink link = (HyperLink)e.Row.FindControl("requestNumberHyperLink");


        link.Text = requestNumber.ToString();

        link.NavigateUrl = PageMethods.





produces this url:


which is missing the "myvirtualfolder" part after localhost, and fails.

Any ideas?


May 26, 2008 at 4:32 PM
Hello Carl,

Some quick questions to help determine what can be the reason for this behavior:
  • Is there an UrlFormat attribute on the page method? In this case, what's its value?
  • Could you copy the Page element that corresponds to the page in PageList.xml?
  • Could you copy the code for the EditRequest method, which is generated in PageList.xml.cs?
  • Which version of PageMethods are you using? You can find this information in PageList.xml, PageList.xml.cs or in the menu under "Tools | PageMethods"