DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 3 Aug 2007 15:51:26 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    tshad
          2    Milosz Skalecki [MCAD]
          3    tshad


NavigateURL/DataNavigateURLFormatString and Session Variable   
I gave up on the Page.ResolveURL and just got the Current Path from the 
Request.ServerVariables("Path_Info") and put it in a session variable.  I 
thought I could use a session variable to pass the path in since the other 
won't work.  But I am getting the same type of error.

         <asp:HyperLinkColumn ItemStyle-Width="190" DataTextField="JobTitle"
          DataTextFormatString="{0}" DataNavigateUrlField="PositionID"
          DataNavigateUrlFormatString='<%= session("PagePath") 
%>displayPositionNS.aspx?PositionID={0}'
          headertext="Job Title"
          ItemStyle-VerticalAlign="Top"
          sortexpression="JobTitle"/>

session("PagePath") = /JobSeeker/

The link in the DataGrid:

http://www.stw.com/applicant/<%=%20session("PagePath")%20%>displayPositionNS.aspx?PositionID=442

Not only won't it use the session variable - it still uses the Controls path 
(/applicant/) and not the Path I tell it to use.

I also tried it with the <%# %> with the same result.

Is there anyway to use a session variable with the Hyperlink???

Thanks,

 Tom
Date:Fri, 3 Aug 2007 15:51:26 -0700   Author:  

RE: NavigateURL/DataNavigateURLFormatString and Session Variable   
Hi there,

First, you cannot use <%=%> for server controls, the only allowed are data 
bound <%# %> (in conjunction with a DataBind() method call) and resource <%$ 
%> expressions. Second, use ~ (tilde) in the URL as it is resolved 
automatically by all the controls (by calling ResolveUrl method):

<asp:HyperLinkColumn 
	ItemStyle-Width="190" DataTextField="JobTitle"
	DataTextFormatString="{0}" 
	DataNavigateUrlField="PositionID"
	DataNavigateUrlFormatString="~/displayPositionNS.aspx?PositionID={0}"
	HeaderText="Job Title"
	ItemStyle-VerticalAlign="Top"
	SortExpression="JobTitle"/>


hope this helps
-- 
Milosz


"tshad" wrote:


> I gave up on the Page.ResolveURL and just got the Current Path from the 
> Request.ServerVariables("Path_Info") and put it in a session variable.  I 
> thought I could use a session variable to pass the path in since the other 
> won't work.  But I am getting the same type of error.
> 
>          <asp:HyperLinkColumn ItemStyle-Width="190" DataTextField="JobTitle"
>           DataTextFormatString="{0}" DataNavigateUrlField="PositionID"
>           DataNavigateUrlFormatString='<%= session("PagePath") 
> %>displayPositionNS.aspx?PositionID={0}'
>           headertext="Job Title"
>           ItemStyle-VerticalAlign="Top"
>           sortexpression="JobTitle"/>
> 
> session("PagePath") = /JobSeeker/
> 
> The link in the DataGrid:
> 
> http://www.stw.com/applicant/<%=%20session("PagePath")%20%>displayPositionNS.aspx?PositionID=442
> 
> Not only won't it use the session variable - it still uses the Controls path 
> (/applicant/) and not the Path I tell it to use.
> 
> I also tried it with the <%# %> with the same result.
> 
> Is there anyway to use a session variable with the Hyperlink???
> 
> Thanks,
> 
>  Tom
> 
> 
> 
Date:Fri, 3 Aug 2007 16:10:01 -0700   Author:  

Re: NavigateURL/DataNavigateURLFormatString and Session Variable   
"Milosz Skalecki [MCAD]"  wrote in message 
news:B95FA67D-F1D7-45C5-95C4-508B26C6C3D2@microsoft.com...

> Hi there,
>
> First, you cannot use <%=%> for server controls, the only allowed are data
> bound <%# %> (in conjunction with a DataBind() method call) and resource 
> <%$
> %> expressions. Second, use ~ (tilde) in the URL as it is resolved
> automatically by all the controls (by calling ResolveUrl method):


Actually, that is not the case.  Apparently, it doesn't call the ResolveURL 
(which sends back the Current Page URL).  No matter how you do it, it comes 
back with the Controls' URL.  Which means if you do it the normal way, you 
absolutely cannot call it from different folders.  If  you call it this way, 
you will get the path of the control.

For example:

If you have

http://www.stw.com/jobseeker/displayCompanyJobs.aspx  and
/applicant/displayCompanyJobs.ascx                       (my control loaded 
into displayCompanyJobs.aspx)

Where displayCompanyJobs trys to load displayCompanyOverview.aspx - It will 
use the path of the Control (www.stw.com/applicant/ and not 
www.stw.com/jobSeeker as you would expect and is done by every other 
Redirect object or tag)

The ~ really doesn't do anything, as far as I can tell.  Here is what will 
happen for different ways of calling displayCompanyOverview.

<asp:Hyperlink Text="with ~/ " NavigateUrl="~/displayCompanyOverview.aspx" 
runat="server"/><br>

http://www.stw.com/displayCompanyOverview.aspx     (where is the applicant 
or jobseeker folder????)

<asp:Hyperlink Text="with ~/ and jobseeker " 
NavigateUrl="~/jobseeker/displayCompanyOverview.aspx" runat="server"/><br>

http://www.stw.com/JobSeeker/displayCompanyOverview.aspx    (Current Page 
Path but worthless as it is called from the control and not the page)

<asp:Hyperlink Text="with / " NavigateUrl="/displayCompanyOverview.aspx" 
runat="server"/><br>

http://www.stw.com/displayCompanyOverview.aspx

<asp:Hyperlink Text="with no tilde or / " 
NavigateUrl="displayCompanyOverview.aspx" runat="server"/><br>

http://www.stw.com/applicant/displayCompanyOverview.aspx        (Controls 
Path)

If you call ResolveURL as so:
  test = Page.ResolveUrl("displayCompanyOverview.aspx")
  trace.warn("ResolveURL = " & test)

You will get in the trace:

ResolveURL = /JobSeeker/displayCompanyOverview.aspx

As you see ResolveURL gives you the Current Page Path.

You cannot use Page.ResolveURL in your HyperLink, however.  It doesn't 
resolve it.  And you cannot use ResolveClientURL in .Net 1.1.  You get the 
error - " not accessible in this context because it is 'Private'"

I also tried to put the path in a session variable and found I couldn't get 
the inline call to get the session variable.

These are things you can't do.  Here is what you can do and it works well.

I have and found a very good solution - similar to your approach.  I am 
using the OnPreRender event - which gives me the line that needs to be 
handled and I don't have to check to see if the object is a correct type of 
object.
Works great.

Here is what I did - for anyone in the same situation.

The ServerVariables("PATH_INFO") in my situation gives me: 
/JobSeeker/displayCompanyJobs.aspx  So I just take out the 
displayCompanyJobs.aspx and I have the Current pages path.  As the session 
variables - as far as I could tell, you cannot use this 
ServerVariables("PATH_INFO") in the Hyperlink object.

The event I created was:

 Sub FixHyperLink(s as Object, e as EventArgs)
  s.NavigateURL = 
request.ServerVariables("PATH_INFO").Substring(0,request.ServerVariables("PATH_INFO").LastIndexOf("/")+1) 
& s.NavigateURL
 end Sub

Then for all my Hyperlinks I add:

OnPreRender="FixHyperLink"

Now my Hyperlink looks like:

<asp:hyperlink text='<%# Container.DataItem("JobTitle")%>' NavigateUrl='<%# 
"displayPositionNew.aspx?PositionID=" & Container.DataItem("PositionID") %>' 
OnPreRender="FixHyperLink" runat="server" />

I also changed my HyperLinkColumns to:

    <asp:TemplateColumn sortexpression="JobTitle" ItemStyle-Width="250px" 
HeaderStyle-Width="250px"
             headertext="Job Title" ItemStyle-VerticalAlign="Top" 
runat="server">
        <ItemTemplate>
             <asp:HyperLink ID="JobTitle"
              NavigateURL='<%# "displayPositionNew.aspx?PositionID=" & 
Container.DataItem("PositionID") %>'
              Text='<%# Container.DataItem("JobTitleDesc")%>'
              OnPreRender="FixHyperLink"
              runat="server"/>
       </ItemTemplate>
    </asp:TemplateColumn>

There is no event on HyperLinkColumns and the problem with ItemDataBound and 
RowDataBound is that you need to check all the controls in the rows to find 
any HyperLinkColumn type fields then make the change.

Thanks,

Tom


>
> <asp:HyperLinkColumn
> ItemStyle-Width="190" DataTextField="JobTitle"
> DataTextFormatString="{0}"
> DataNavigateUrlField="PositionID"
> DataNavigateUrlFormatString="~/displayPositionNS.aspx?PositionID={0}"
> HeaderText="Job Title"
> ItemStyle-VerticalAlign="Top"
> SortExpression="JobTitle"/>
>
>
> hope this helps
> -- 
> Milosz
>
>
> "tshad" wrote:
>
>> I gave up on the Page.ResolveURL and just got the Current Path from the
>> Request.ServerVariables("Path_Info") and put it in a session variable.  I
>> thought I could use a session variable to pass the path in since the 
>> other
>> won't work.  But I am getting the same type of error.
>>
>>          <asp:HyperLinkColumn ItemStyle-Width="190" 
>> DataTextField="JobTitle"
>>           DataTextFormatString="{0}" DataNavigateUrlField="PositionID"
>>           DataNavigateUrlFormatString='<%= session("PagePath")
>> %>displayPositionNS.aspx?PositionID={0}'
>>           headertext="Job Title"
>>           ItemStyle-VerticalAlign="Top"
>>           sortexpression="JobTitle"/>
>>
>> session("PagePath") = /JobSeeker/
>>
>> The link in the DataGrid:
>>
>> http://www.stw.com/applicant/<%=%20session("PagePath")%20%>displayPositionNS.aspx?PositionID=442
>>
>> Not only won't it use the session variable - it still uses the Controls 
>> path
>> (/applicant/) and not the Path I tell it to use.
>>
>> I also tried it with the <%# %> with the same result.
>>
>> Is there anyway to use a session variable with the Hyperlink???
>>
>> Thanks,
>>
>>  Tom
>>
>>
>> 
Date:Mon, 6 Aug 2007 09:41:41 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us