Showing posts with label solution. Show all posts
Showing posts with label solution. Show all posts

Wednesday, March 28, 2012

Tracking Link Clicks

Hi,

I posted this before in the "Web Forms" section, but I was just thinking what I might need is an AJAXian solution.

I'm trying to figure out the best way to track user clicks on links. I could easily do this by making all the links LinkButton's and just use the PostBackUrl property or response.redirect or something like that to send the user on to the page they clicked to.

However, this is not a very good solution because spiders would be unable to crawl these links and I need to have the option of opening the pages from the links in a new browser window at times.

So basically if the HyperLink control had an "OnClick" property that fired before doing the default thing (ie following the link), that would be ideal, but it does not.

So I was just wondering if anyone had any good ideas on how to create a "link" control that would allow search engines to crawl the links, allow me to at times open the linked page into a new browser window (ie target=_blank), and also to record the user clicks into a database?

Would there be a way to use the javascript onclick event to fire some function that calls a service or something on the server to update my database with the click information? If so how would I do that?

Hi,

I just replied in your other thread. Though now I've seen you mention AJAX this would allow you to accomplish a lot more.

Cheers,

Al

Saturday, March 24, 2012

Triggers Across Content Control

I've seen this posted a few times but no concrete solution or identification of the problem. I have 2 content section. The first one has buttons that should trigger an update in the second content. The second content has an UpdatePanel with the trigger definition. But I get the following error:

The ControlID property of the trigger must reference a valid control.

This is the code:

<

asp:ContentID="Content3"ContentPlaceHolderID="MainContentHeaderHolder"Runat="Server">
<strong>Property Details :: Options</strong>
<div>
<asp:ButtonID="btnNewResident"Text="[New Resident]"OnClick="ViewResidentPanel"runat="server"/>
</div>
</asp:Content>
<asp:ContentID="Content4"ContentPlaceHolderID="MainContentHolder"Runat="Server">
<atlas:UpdatePanelID="upNewRecordPanels"runat="Server">
<ContentTemplate>
......
</ContentTemplate>
<Triggers>
<atlas:ControlEventTriggerControlID="btnNewResident"EventName="Click"/>
<atlas:ControlEventTriggerControlID="btnNewContactNumber"EventName="Click"/>
<atlas:ControlEventTriggerControlID="btnNewAuthorizedGuest"EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
</asp:Content>

Is there a solution or is this a bug or by design?

{Bump}

Any thoughts from anyone on this? Is it by design that you cannot cross content sections or does it need to be done a different way?


Hi
I bumped into the same problem. It makes some kind of sense, because the controls in the other content control will be loaded in a different container and from what I've seen the UpdatePanel cannot find it.
One solution would be to edit the control id to its UniqueID:
<atlas:ControlEventTriggerControlID="MainContentHeaderHolder$btnNewResident"EventName="Click"/>
or
<atlas:ControlEventTriggerControlID="ctl00$MainContentHeaderHolder$btnNewResident"EventName="Click"/>

In both cases the error disappears, but i didn't test if the trigger gets fired. An alternative would be to add the trigger from the code using the UniqueId (easier if you later need to modify the control herarchy).

Anther solution (the one i used) would be to relate the trigger to a control that gets changed inside the UpdatePanel, like a panel.Visible - you probably have one that changes, otherwise you wouldn't need to update it. Although the controls inside the content template of the update panel do not appear as choices in the designer, you can add the trigger manually in source view.

I hope this helps
Vlad

Trouble canceling an Ajax webservice

I have been searching how to cancel a webservice request in javascript and the standard solution does not seem to work for me. I call the webservice like this.

_request = ClientServices.GetPolyListings(myPoints, SearchComplete, SearchFailed);

_request seems to always be undefined after I do this.. I checked the value during through the debugger and even tried sleeping the thread in the webservice to postpone it for testing. Nothing seems to work. I have this code which never executes because its undefined.

if(_request)

_request.get_executor().abort();

Try with:

_request = ClientServices._staticInstance.GetPolyListings(myPoints, SearchComplete, SearchFailed);
Check:
http://geekswithblogs.net/rashid/archive/2007/07/14/Cancel-a-Web-Service-Call-in-Asp.net-Ajax.aspx

Thank you works great. Do not know how I forgot the _staticInstance because I am pretty sure I looked at that site already. Thanks Solved.


Would you pls mark it as answer.