开发者

Asp.net RenderControl method not rendering autopostback for dropdownlist

开发者 https://www.devze.com 2022-12-22 22:14 出处:网络
i am bit confused as to why asp.net does not render a dropdownlist with the autopostback property set to true when using the RenderControl method.

i am bit confused as to why asp.net does not render a dropdownlist with the autopostback property set to true when using the RenderControl method.

eg

 Dim sw As New IO.StringWriter
    Dim tw As New HtmlTextWriter(sw)

    Dim table As New Table

    table.Rows.Add(New TableRow)
    Dim tr As TableRow = table.Rows(0)

    开发者_开发百科tr.Cells.Add(New TableCell)
    Dim tc As TableCell = tr.Cells(0)

    Dim ddlMyValues As New DropDownList
    ddlMyValues.ID = "ddl1"

    ddlMyValues.Items.Add("Test1")
    ddlMyValues.Items.Add("Test2")
    ddlMyValues.Items.Add("Test3")
    ddlMyValues.AutoPostBack = True

    tc.Controls.Add(ddlMyValues)
    table.RenderControl(tw)

    Debug.WriteLine(sw.ToString)

my output renders the dropdown list without the onchange="javascript:setTimeout('__doPostBack(\ddl1\',\'\')', 0)" that is generated by asp.net when using the dropdownlist normally.

Is there a work around to this?


Just a guess, but it might be because it's not inside a form element. Why would you want to do this anyway?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号