我有这个函数,我在页面int事件中调用
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
返回的值是锚,但不呈现CommandName和CommandArgument 我该怎么做才能呈现CommandName和CommandArgument
答案 0 :(得分:1)
CommandName和CommandArgument永远不会呈现在输出HTML中,它们会在随附的JavaScript中使用。
此外,您应该将控件添加到控件集合中,而不是手动呈现它。这样你就可以确定它是整个页面生命周期的一部分。
Controls.Add(Lb)