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: Tue, 14 Aug 2007 16:05:20 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    BobLaughland
          2    Ladislav Mrnka
          3    Alexey Smirnov


Using an asp:hyperlink versus an asp:linkbutton   
Hi There,

I need a control on my site that is a hyperlink style control, but it
must,

1) Have a property that can hold where the hyperlink is pointing to.
(e.g. like the NavigateUrl property in the asp:hyperlink control).
2) Also can call my own method when the user clicks on the link (e.g.
like the Click event in the asp:linkbutton control).

Anyway it seems that the 2 controls separately do what I want, but
don't both do everything I want.

I will explain why. Basically what I have is a page which shows the
results from the user doing a search. It lists the results from the
search as hyperlinks (kind of like doing a search in google but local
to our site). When the user clicks on one of the links I would like it
to call a piece of my code to log which link they clicked for
statistical purposes. Also note that it has to know the page that it
is linking to (the asp:linkbutton does not have a NavigateUrl property
so this does not work).

Failing that the only other way I can think of doing it would be to
subclass one of the above controls and add the functionality, but that
sounds messy to me.
Date:Tue, 14 Aug 2007 16:05:20 -0700   Author:  

RE: Using an asp:hyperlink versus an asp:linkbutton   
Hi,
you are trying to combine two absolutly different functionality. NavigateUrl 
is used in browser to construct new GET HTTP request and point it to 
described resource on web server - this means you actual page cannot response 
to this request because it will not be posted back. On the other hand link 
button uses post back mechanism = user usually constructs POST HTTP (type of 
request can be changed) request and sends it to you current page for 
processing.

You have to choose another approach to solve your requirements. You can use 
link button and post back you url or any other identifier as command 
argument. Then you can handle logging in on command event and transfer 
(server side - url will be same as search page) or redirect (client side - if 
you want url to reflect actual user choice but it means one more round trip) 
to page you want to display as response to user click. Another approach you 
can choose is to use hyperlink and add some query string to NavigateUrl to 
inform your application to log user request. You can handle logging in each 
page or for example in custom http module.

Regards,
Ladislav 

"BobLaughland" wrote:


> Hi There,
> 
> I need a control on my site that is a hyperlink style control, but it
> must,
> 
> 1) Have a property that can hold where the hyperlink is pointing to.
> (e.g. like the NavigateUrl property in the asp:hyperlink control).
> 2) Also can call my own method when the user clicks on the link (e.g.
> like the Click event in the asp:linkbutton control).
> 
> Anyway it seems that the 2 controls separately do what I want, but
> don't both do everything I want.
> 
> I will explain why. Basically what I have is a page which shows the
> results from the user doing a search. It lists the results from the
> search as hyperlinks (kind of like doing a search in google but local
> to our site). When the user clicks on one of the links I would like it
> to call a piece of my code to log which link they clicked for
> statistical purposes. Also note that it has to know the page that it
> is linking to (the asp:linkbutton does not have a NavigateUrl property
> so this does not work).
> 
> Failing that the only other way I can think of doing it would be to
> subclass one of the above controls and add the functionality, but that
> sounds messy to me.
> 
> 
Date:Wed, 15 Aug 2007 00:04:00 -0700   Author:  

Re: Using an asp:hyperlink versus an asp:linkbutton   
On Aug 15, 9:04 am, Ladislav Mrnka
 wrote:

> Hi,
> you are trying to combine two absolutly different functionality. NavigateUrl
> is used in browser to construct new GET HTTP request and point it to
> described resource on web server - this means you actual page cannot response
> to this request because it will not be posted back. On the other hand link
> button uses post back mechanism = user usually constructs POST HTTP (type of
> request can be changed) request and sends it to you current page for
> processing.
>
> You have to choose another approach to solve your requirements. You can use
> link button and post back you url or any other identifier as command
> argument. Then you can handle logging in on command event and transfer
> (server side - url will be same as search page) or redirect (client side - if
> you want url to reflect actual user choice but it means one more round trip)
> to page you want to display as response to user click. Another approach you
> can choose is to use hyperlink and add some query string to NavigateUrl to
> inform your application to log user request. You can handle logging in each
> page or for example in custom http module.
>
> Regards,
> Ladislav
>


I fully agree. In addition to Ladislav's proposals you can try
following:

- use Hyperlink Control with onclientclick property where you can call
an Ajax function before client will be redirected to the NavigateUrl.
- use Hyperlink Control pointed to another webform, e.g. redirect.aspx?
url=http://mysite/mypage where url will be your target url and write
your statistics from the redirect.aspx
- use HttpHandler and check HTTP_REFERER. if the referrer is the
address of your search page then you can log that request.
Date:Wed, 15 Aug 2007 00:20:56 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


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