Problem with Ajax Async Click and Redirect


Author
Message
Anna Lear
Anna Lear
Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)
Group: Forum Members
Posts: 12, Visits: 1
I'm trying to set up an auto-redirect when the user clicks on a diagram element. It's mostly working fine, except for a couple connector elements. When I click on those, I end up redirected to a wrong page.

I have the drawing view set up this way:
<ndwc:NDrawingView ID="NDrawingView1" runat="server" Height="529px" Width="738px" BorderStyle="None" EnableTheming="false" AjaxEnabled="True" OnQueryAjaxTools="NDrawingView1_QueryAjaxTools"></ndwc:NDrawingView>

Then I have a method on the page that displays the diagram that sets the interactivity style on the shapes:
foreach (NShape node in NDrawingView1.Document.ActiveLayer.Children(new NInstanceOfTypeFilter(typeof(NShape))))
{
var interactivityStyle = new NInteractivityStyle {
GenerateImageMapObject = true,
UrlLink =
new NUrlLinkAttribute(@"/OtherPage.aspx?SelectedElement=" +
Server.HtmlEncode(node.Name), false)
};
node.Style.InteractivityStyle = interactivityStyle;
}

And finally, the contents of the QueryAjaxTools handler:
protected void NDrawingView1_QueryAjaxTools(object sender, EventArgs e)
{
NDrawingView1.AjaxTools.Add(new NAjaxMouseClickCallbackTool(true, true));
NDrawingView1.AjaxTools.Add(new NAjaxRedirectTool(true));
}

I have verified that the diagram itself is valid and the element clicks has the correct InteractivityStyle set, with the correct URL.

However, let's say the problem element's name is A. Some other element on the diagram is called B. Where I expect to end up at OtherPage.aspx?SelectedElement=A, I am instead redirected to OtherPage.aspx?SelectedElement=B.

Are there any particular spots I should check to try and figure out what's going on? The diagram? My code?

Thanks.
Pavel Vladov
Pavel Vladov
Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)
Group: Forum Members
Posts: 33, Visits: 2

Hi Anna,

If you are sure that the URLs are set correctly for each element, then may be this is a hit test related issue if your elements overlap. You must assign the proper Z order (according to the layout logic of your application) of such elements to avoid hit testing problems.

Let me know if you have questions or comments.

Cheers,
Pavel


Anna Lear
Anna Lear
Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)
Group: Forum Members
Posts: 12, Visits: 1

Pavel,

Thanks for the your reply. Do you have any tips for what the z-orders should be? Should all my shapes have the same z-order?

Thanks.


Pavel Vladov
Pavel Vladov
Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)
Group: Forum Members
Posts: 33, Visits: 2
Anna, the best way is just to put the shapes one after another in the proper order - the shapes that you place in the document last will have the highest ZOrder and thus they will be shown above the shapes that are added before theme if there's overlapping. You can also use som properties of the shapes such as BringToFront, SendToBack, BringForward and SendBackward to control the ZOrder of the shapes.

If you have any questions or comments let me know.

Cheers,
Pavel
Anna Lear
Anna Lear
Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)Junior Member (12 reputation)
Group: Forum Members
Posts: 12, Visits: 1

Makes sense. Unfortunately, I'm not sure this applies to my situation, since none of the shapes in my diagram overlap. It's just a few rectangles and connectors between them.

I'm loading a previously created diagram from file instead of generating it programmatically, so I don't have much control over the shape order or positioning. All I do is loop through the shapes to assign proper InteractivityStyles as described in my original post. Then when I click on one of my connectors, for some reason a rectangle in a different part of the diagram is chosen as the shape I clicked on.

On the same diagram, if I don't use the AjaxRedirectTool but instead handle the AsyncClick event and do my own hit testing, the correct shapes are returned for all clicks:

protected void NDrawingView1_AsyncClick(object _sender, EventArgs _e)
{ 
var args = _e as NCallbackMouseEventArgs;
NNodeList nodes = NDrawingView1.HitTest(args);
}

I'm not sure what the difference is between that code and the hit testing that AjaxRedirectTool provides.


Pavel Vladov
Pavel Vladov
Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)Forum Member (34 reputation)
Group: Forum Members
Posts: 33, Visits: 2
Hi, Anna. If you load the diagram from file, please send it to our support mail - support@nevron.com so that I can analyze it and tell you what's the problem.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search