i have master page , default.aspx page. drop down <select> on master page.
i want select month drop down on master page , assign variable in different class. then, default.aspx page must use variable select data database date equals date assigned variable.
the reason why select on master page, because selector should on all pages through out site.
the main thing causing issue me page_load event on defauls.aspx page fires before page_load in master page.
if try page_init, works, selector code keeps returning 0 value. tried using hiddenfield , failed. appreciate on this!
site1.master:
<select id="selectmonth" runat="server" onchange="cmbchange();"> <option id="select" value="0">[select month]</option> <option id="january" value="1">january</option> <option id="february" value="2">february</option> <option id="march" value="3">march</option> <option id="april" value="4">april</option> <option id="may" value="5">may</option> <option id="june" value="6">june</option> <option id="july" value="7">july</option> <option id="august" value="8">august</option> <option id="september" value="9">september</option> <option id="october" value="10">october</option> <option id="november" value="11">november</option> <option id="december" value="12">december</option> </select> <script type="text/javascript"> function cmbchange(obj) { var cmbvalue = document.getelementbyid("selectmonth").value; __dopostback('selectmonth', cmbvalue); } </script> site1.master.cs:
protected void page_load(object sender, eventargs e) { int month = convert.toint32(selectmonth.value); if (month > 0) { date.month = month; } else { date.month = datetime.now.month; } } default.aspx:
protected void page_load(object sender, eventargs e) { // example var sql = "select * data month = " + date.month; } date.cs:
public static class date { public static int month { get; set; } } thanks!
why not try using default.aspx.vb page_prerender, , use page_load on masterpage value then?
or alternatively use include:
<%@ mastertype virtualpath="~/masterpages/site.master" %> and call function wrote in masterpage dropdown value using:
master.functionnamedonmasterpage() here link msdn site on how reference masterpage content
Comments
Post a Comment