Getting posted value (ASP.NET)
I am building a DropDownList
control dynamically.
Constraining this discussion to within just the OnInit()
method / state in the asp.net 开发者_JS百科lifecycle, is the only way to see the dropdownlist's posted value to look at the Request.Form
NameValueCollection?
I.e. Im aware that the dropdownlist's viewstate is restored by the time OnLoad()
is reached, but I need it's value before then (im pretty sure LoadViewState($object) is of no use?)
try page_preload event to read viewstate
Private Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad
Dim s As String = DropDownList1.Text
End Sub
Other solution could be
Try this in Init event
VB
dim s as string = Request.Params("DropDownList1")
C#
string s = Request.Params["DropDownList1"];
精彩评论