I have this function that I call in page int event
Protected Function RenderLB(text As String, Id As String, argument As String) As [String]
Using Lb = New System.Web.UI.WebControls.LinkButton
Lb.Text = text
Lb.ID = Id
Lb.Attributes.Add("runat", "Server")
Lb.CommandName = "RedirectFillsession"
Lb.CommandArgument = argument
Dim StringBuilder = New System.Text.StringBuilder()
Using stringWriter = New System.IO.StringWriter(StringBuilder)
Using htmlTextWriter = New System.Web.UI.HtmlTextWriter(stringWriter)
Lb.RenderControl(htmlTextWriter)
End Using
End Using
Return StringBuilder.ToString()
End Using
End Function
the returned value is anchor but CommandName and CommandArgument are not rendered what should I do to render the CommandName and CommandArgument
CommandName and CommandArgument are never rendered into the output HTML, they are used in the accompanying JavaScript.
Also, you should add your control to the controls collection instead of rendering it manually. That way you can be sure its part of the entire Page Life Cycle.
Controls.Add(Lb)