I am using a modal popup extender which contains a panel having three textboxes and two buttons. I want to fill the textbox values with my specifications (the date selected)..but not getting it successfully.
protected void myCal_SelectionChanged(object sender, EventArgs e)
{
ModalPopupExtender1.Show();
TextBoxStart.Text = myCal.SelectedDate.ToString();
TextBoxEnd.Text = myCal.SelectedDate.ToString();
}
Designer is
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Calendar ID="myCal" runat="server" Height="600px" width="900px"
BorderColor="#F2F3F4" BorderWidth="3px" DayStyle-BorderWidth="1px"
TodayDayStyle-BackColor="#82CAFF" NextPrevFormat="ShortMonth"
SelectionMode="Day" DayHeaderStyle-Height="30px"
TitleStyle-BackColor="#CBE3F0" TitleStyle-ForeColor="#153E7E"
OtherMonthDayStyle-ForeColor="#B4CFEC" NextPrevStyle-ForeColor="#2554C7"
CssClass="mGrid" onselectionchanged="myCal_SelectionChanged">
<DayHeaderStyle Height="30px" /><TitleStyle Height="50px" />
<DayStyle BorderWidth="1px" HorizontalAlign="Left" VerticalAlign="Top" />
<TodayDayStyle BackColor="#CBE3F0" />
</asp:Calendar>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="ButtonDummy" PopupControlID="pnlSelect">
</ajaxToolkit:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:Panel ID="pnlSelect" runat="server" width="200px" Height="200px">
<table border="0" cellspacing="6" cellpadding="0" style="background-color: white">
<tr>
<td align="right"></td>
<td>
<h2>New Appointment</h2>
</td>
</tr>
<tr>
<td align="right">Start Date:</td>
<td>
<asp:TextBox ID="TextBoxStart" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right">End Date:</td>
<td>
<asp:TextBox ID="TextBoxEnd" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right">Name:</td>
<td>
<asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right"></td>
<td>
<asp:Button ID="ButtonOK" runat="server" OnClick="ButtonOK_Click" Text="OK" />
<asp:Button ID="ButtonCancel" runat="server" Text="Cancel" OnClick="ButtonCancel_Click" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
What can be wrong?
As these textboxes placed out of UpdatePanel they are not updated on async request. Place them into the same UpdatePanel or wrap by another one UpdatePanel and set UpdateMode to “Always” like below:
Try to set
ChildrenAsTriggersproperty of the UpdatePanel1 totrueor move ModalPopupExtender1 to UpdatePanel2.Also, you can move PopupExtender and his target dummy button out of the UpdatePanel1 and swap pnlSelect with UpdatePanel2: