1

I am trying to render a hyperlink to html. ( etc)

When the page loads it works fine. (and lots 10 links) on the update panel it hits the same function and tries to get another 10 links. I set the navigationURL to something like

"../Folder/Mypage.aspx?498592ghjgfosdfgo"

It is set identically both times(load and updatepanel postback) but when i try to render it to html the second time (on the update panel) it adds "../" to the front so i end up with

"../../Folder/Mypage.aspx?498592ghjgfosdfgo"

The function where it changes here

Public Shared Function RenderControl(ByVal c As Control) As String
    Dim sw As New IO.StringWriter
    Dim htmlw As New HtmlTextWriter(sw)
    c.RenderControl(htmlw)
    Return sw.ToString
End Function

c is the hyperlink which has the propertry navigationurl (this never gets changed) but the sw which ends up looking like this on load

<a id="lnkView" href="../Folder/mypage.aspx?AnTfh0ZsFP9NCxiBpM+Zd11cI+AUOF93HZQtumPgzMKky0PejGrda9I6kCFn070dOsIfq0M2AgI=">View</a>}

and this on panel update

    <a id="lnkView" href="../../Folder/mypage.aspx?AnTfh0ZsFP9NCxiBpM+Zd11cI+AUOF93HZQtumPgzMKky0PejGrda9I6kCFn070dOsIfq0M2AgI=">View</a>}

And cannot work out where the ../ comes from for the life of me! HELP :)

Steve
  • 2,971
  • 7
  • 38
  • 63
  • 1
    Have just spend some time looking into this myself. It comes down to this: when the *update panel* makes its request, the request looks like `whatever/page.aspx/methodname`, so other parts of the ASP.NET engine think you're one level deeper than you actually are. This is presumably down to page methods being 'bolted on' later. Will post an answer if I come up with a solution. – AakashM Aug 17 '12 at 14:52
  • Are you actually using `UpdatePanel`, or explicit AJAX requests? I have a workaround in the latter case, but I can't repro with plain `UpdatePanel`s. – AakashM Aug 17 '12 at 15:21

1 Answers1

1

Try using ~/Folder/mypage.aspx?XYZ as your NavigateURL.

When you say "on the update panel," do you mean on a user control that is inside an update panel?

matt-dot-net
  • 4,204
  • 21
  • 24
  • 1
    yeh in a updatepanel I have a table which im adding rows to e.g TableId.Rows.Add(tr) I tried using the ~ but it produces the same results when c.RenderControl(htmlw) is applied on the page load. The ~ is removed and replaced with ../ and on the updatepanel it has ../../ again! – Steve Jul 08 '10 at 08:16