I have a custom control which is rendered as a hyperlink:
Public Class TestControl
Inherits System.Web.UI.WebControls.WebControl
Implements IPostBackEventHandler
Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
Trace.WriteLine("Hyperlink 1 clicked")
End Sub
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
writer.WriteLine("<a href=""{0}"" id=""{1}"">Hyperlink 1</a>", _
Page.ClientScript.GetPostBackClientHyperlink(Me, "Hyperlink 1"), _
Me.ClientID)
End Sub
End Class
This works fine. It also works nicely when put inside an UpdatePanel
: Only the UpdatePanel is refreshed, no full postback is performed.
Now I would like to output a second hyperlink in the Render
method. If I use the same id (Me.ClientID
), everything works nicely, but this obviously results in broken HTML (no two controls are allows to have the same id
attribute). If I use different client IDs (like Me.ClientID & "_1"
and Me.ClientID & "_2"
), a full postback is performed when the hyperlinks are clicked.
Is there some way to tell ASP.NET AJAX: "All postbacks of the following client IDs should be done asynchronously: ..."?