Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Can't get value for DropDownList
Jude Lobo
Dec 17 2017 1:59 AM
206
Reply
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:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="about-content" style="height:600px">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>Theme1</asp:ListItem>
<asp:ListItem>Theme2</asp:ListItem>
</asp:DropDownList>
</div>
</asp:Content>
Also I'm doing this inside a masterpages contentplaceholder, if that helps.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
ASP.NET AJAX MVC - Calling Controller Method from View
Multiple razor view on one view