Url not working correctly in DataGrid

T

tshad

I have a page that is loading a control from another folder. I want the
references to be from current folder not the folder the control came from.
And that has been working fine in most cases. But not for this one.

This is DataGrid with a Hyperlink column. The page
www.ft.com/jobseeker/test.aspx is loading a control from
www.ft.com/applicant/login.ascx.

In www.ft.com/applicant/login.ascx I have the following column in my my
datagrid.

<asp:HyperLinkColumn DataTextField="JobTitleDesc" DataTextFormatString="{0}"
DataNavigateUrlField="PositionID"
DataNavigateUrlFormatString="displayPositionNS.aspx?PositionID={0}"
headertext="Job Title"
ItemStyle-Width="250px"
ItemStyle-VerticalAlign="Top"
sortexpression="p.JobTitle"/>

The problem is that the link is showing as
www.ft.com/applicant/displayPositionNS.aspx.PositionID=10 instead of
www.ft.com/jobseeker/displayPositionNS.aspx.PositionID=10 as it should.

I don't want to hard code this as this control is called from a couple of
different places and it should always use the .aspx page location not the
..ascx location.

Does anyone know why this is not working yet it works in other places?

Thanks,

Tom
 
B

Brandon Gano

Try ~/jobseeker/displayPositionNS.aspx. ASP.NET maps (~) to the root folder
of your site.
 
T

tshad

Brandon Gano said:
Try ~/jobseeker/displayPositionNS.aspx. ASP.NET maps (~) to the root folder
of your site.

No, that wouldn't get me what I am trying to do.

I want "displayPositionNS.aspx" to go to the displayPositionNS.aspx in the
current directory. It could also be
www.staffingworkshop.com\employer\DisplayPositionNS.aspx that uses the .ascx
control. In this case, I would want it to open the file in the employer
site. I need it to look at where the original .aspx file is and use that
folder.

Thanks,

Tom
 
T

tshad

Also, on the same page I have:

Response.Redirect("displayCompanyOverview.aspx?CID=" & CompanyID.Text)

This one doesn't go the the "Applicant" folder to get
displayCompanyOverview.aspx - it goes to the JobSeeker or Employer folders
to the file (depending on where the original .aspx page was).

Thanks,

Tom
 
T

tshad

The problem would be even worse if I were to put the Controls in a
/Controls/ folder so that the path to all my controls were in:

/inetpub/wwwroot/stw/controls.

I obviously don't want my links to go to my controls folder to get my pages.
I want them relative to the folder my .aspx folder is.

For example, my page might be in:

/inetpub/wwwroot/stw/jobseeker/ or /inetpub/wwwroot/stw/employer/

and call my control in my /controls/ folder. If I have a hyperlink to
another page, I would want it to get the .aspx page from either the
jobseeker or employer folders depending on where the page I am calling it
from is.

I found that the <asp:hyperlink> has the same problem. The only way around
it seems to be to never use the hyperlink tag and conver all my tables and
links on my pages to do Response.Redirct which works correctly.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top