I'm trying to get value of DropDownList in the OnPreInit event, here's the code for it:
protected override void OnPreInit(EventArgs e)
{
if(Request.Form["DropDownList1"]!=null)
{
var theme = Request.Form["DropDownList1"];
Page.Theme = theme;
}
base.OnPreInit(e);
}
But on debugging it returns null every time, here's the code for the dropdownlist: Also I'm doing this inside a masterpages contentplaceholder, if that helps.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Jinish Gandhi74 reputationPosted Dec 19, 2017, 6:48 AM EST
{
if (Request.Form["DropDownList1"] != null)
{
var theme = DropDownList1.SelectedItem.Value; //you can get the value
Response.Write(theme);
}
}