search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Hyperlink in event box sometimes overridden by redirect in event_click

Asked by Brian
16 years ago.

Hi,
On the BeforeEventRender event I override the display to include a hyperlink
"e.InnerHTML = "<A HREF='NewPage.aspx?ID=" & e.Value & "'>MyLink</A><br />" & e.InnerHTML"

The problem is that the EventClick event contains a statement "Response.Redirect("Edit.aspx")"
What should happen is the browser redirects to "Edit.aspx" if I click anywhere in the event (except the hyperlink I added). If f the hyperlink is clicked it should go to NewPage.aspx.

The browser status bar shows the system tries to navigate to the page as specified in the hyperlink, but the response.redirect in the click_event overrides it.

How can I make the click_event fire unlessthe hyperlink is clicked on, orthe event still fires but I can detect the hyperlink was clicked and skip the line which causes the redirect?

This behaviour is not consistent, sometimes the hyperlink works.

Comment posted by Dan Letecky
16 years ago.
I would try adding the following piece code that prevents event bubbling to the <a> element:

onclick="event.cancelBubble = true; if (event.stopPropagation) event.stopPropagation();"

I'm using this internally in DayPilot. It should work for both FF and IE.
Comment posted by Brian
16 years ago.

Thanks,
That fixed the issue, although i moved the lines intoits own function do reduce the amount to data sent to the browser so each event simply adds "onclick='a(event)'" to the hyperlink.

function a(event)
{
event.cancelBubble = true;
if (event.stopPropagation)
event.stopPropagation();
}

Comment posted by Dan Letecky
16 years ago.
OK and thanks for posting this note. You are right that including the full code in the HTML for each event produces a lot of repeating code.
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.