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 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jinish GandhiPosted Dec 19, 2017, 11:48 AM
{
if (Request.Form["DropDownList1"] != null)
{
var theme = DropDownList1.SelectedItem.Value; //you can get the value
Response.Write(theme);
}
}