For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > July 2007 > Url not working correctly in DataGrid









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Url not working correctly in DataGrid
tshad

2007-07-31, 4:23 am

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
[url]www.ft.com/jobser/test.aspx[/url] 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/displayPositio...x.PositionID=10 instead of
[url]www.ft.com/jobser/displayPositionNS.aspx.PositionID=10[/url] 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


Brandon Gano

2007-07-31, 4:23 am

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


"tshad" <t@home.com> wrote in message
news:OR6$zHy0HHA.5764@TK2MSFTNGP03.phx.gbl...
>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
> [url]www.ft.com/jobser/test.aspx[/url] 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/displayPositio...x.PositionID=10 instead of
> [url]www.ft.com/jobser/displayPositionNS.aspx.PositionID=10[/url] 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
>
>


tshad

2007-07-31, 4:23 am


"Brandon Gano" <bgano@inocompany.com> wrote in message
news:65C7A8CD-BE53-4D2C-B6C6-CA76391A2F92@microsoft.com...
> Try ~/jobser/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\D...PositionNS.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

>
>
> "tshad" <t@home.com> wrote in message
> news:OR6$zHy0HHA.5764@TK2MSFTNGP03.phx.gbl...
from.[color=darkred]
of[color=darkred]
the[color=darkred]
>



tshad

2007-07-31, 7:12 pm

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 JobSer or Employer folders
to the file (depending on where the original .aspx page was).

Thanks,

Tom

"tshad" <t@home.com> wrote in message
news:eZOdJry0HHA.4184@TK2MSFTNGP06.phx.gbl...
>
> "Brandon Gano" <bgano@inocompany.com> wrote in message
> news:65C7A8CD-BE53-4D2C-B6C6-CA76391A2F92@microsoft.com...
> folder
>
> 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\D...PositionNS.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
>
> from.
> of
> the
>
>



tshad

2007-07-31, 7:12 pm

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/jobser/ 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
jobser 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

"tshad" <t@home.com> wrote in message
news:uZeN4740HHA.464@TK2MSFTNGP02.phx.gbl...
> 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 JobSer or Employer folders
> to the file (depending on where the original .aspx page was).
>
> Thanks,
>
> Tom
>
> "tshad" <t@home.com> wrote in message
> news:eZOdJry0HHA.4184@TK2MSFTNGP06.phx.gbl...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com