How to populate second dropdownlist without postback? - asp.net

I have many dropdownlists and textboxes in a single page. I have done validations on textboxes. Each dropdownlist populate another dropdownlist.
The problem is, all existing validation messages are disappear when selectedindexchanged event fired. How to populate second dropdownlist without postback?
<asp:Content ID="Content1" ContentPlaceHolderID="mainContentPlaceholder" runat="server">
<asp:Panel ID="Panel1" runat="server" CssClass="formattingPanel" ScrollBars="Vertical">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
<ContentTemplate>
<table>
<tr>
<td>Title </td>
<td><asp:DropDownList ID="ddlTitle" runat="server" OnSelectedIndexChanged="ddlTitle_SelectedIndexChanged" AutoPostBack="true" />
<asp:TextBox ID="txtOther" runat="server" Visible="false" Text="" Width="33%"/>
</td>
</tr>
<tr>
<td> Nname </td>
<td> <asp:TextBox ID="txtName" runat="server" /> </td>
</tr>
<tr>
<td> Address1 </td>
<td> <asp:TextBox ID="txtAddress1" runat="server" /> </td>
</tr>
<tr>
<td> Address2 </td>
<td> <asp:TextBox ID="txtAddress2" runat="server"/> </td>
</tr>
<tr>
<td> Postcode </td>
<td> <asp:TextBox ID="txtPostcode" runat="server" /> </td>
</tr>
<tr>
<td> Telephone </td>
<td> <asp:TextBox ID="txtTelephone" runat="server" />
<asp:RegularExpressionValidator ID="regexTelephone" runat="server" ControlToValidate="txtTelephone" ErrorMessage ="* Numbers only & no spaces"
ValidationExpression ="^\d+" ForeColor="Red"> </asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td> Email </td>
<td> <asp:TextBox ID="txtEmail" runat="server" />
<asp:RegularExpressionValidator ID="regexEmail" runat="server" ValidationExpression="\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtEmail" ErrorMessage="* Invalid Email" ForeColor="Red" > </asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>Title 1</td>
<td>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlType1" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList ID ="ddlType1" runat ="server" OnSelectedIndexChanged="ddlType1_OnSelectedIndexChanged" AutoPostBack="true" />
<asp:DropDownList ID ="ddlSubType1" runat ="server" Visible="false" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td> Title 2 </td>
<td>
<asp:DropDownList ID ="ddlType2" runat ="server" OnSelectedIndexChanged="ddlType2_OnSelectedIndexChanged" AutoPostBack="true"/>
<asp:DropDownList ID ="ddlSubType2" runat ="server" Visible="false"/>
</td>
<tr>
<tr>
<td> Title 3 </td>
<td>
<asp:DropDownList ID ="ddlType3" runat ="server" OnSelectedIndexChanged="ddlType3_OnSelectedIndexChanged" AutoPostBack="true"/>
<asp:DropDownList ID ="ddlSubType3" runat ="server" Visible="false"/>
</td>
<tr>
---- upto 8 dropdownlist sams as above
<tr>
<td> <asp:Button ID="btnSave" runat="server" Text ="SAVE" OnClick="btnSave_Click"/> </td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</asp:Content>
I have done ddl binding using c# code..

Related

Control inside repeater causing full postback even after keeping in update panel

In my page, I have one search button and a repeater. I have wrapped everything inside UpdatePanel. My search button do not causes full postback, i.e ideal but RadioButtonList inside Repeater control does. I have no idea what to do.
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<table align="center" border="1" cellspacing="0" class="tabmn6">
<tr id="trheader" runat="server">
<th id="trEdit" runat="server">Edit</th>
<th>User Name </th>
<th>Role</th>
<th>From Date</th>
<th>To Date</th>
<th>Comment</th>
<th>Status</th>
</tr>
<asp:Repeater ID="rpUserDetails" runat="server" OnItemDataBound="rpUserDetails_ItemDataBound">
<ItemTemplate>
<tr>
<td id="tdRPEdit" runat="server" align="center">
<input type="button" class="editbtn" name="btnEdit" id="btnEdit" runat="server" onclick='<%# string.Format("javascript:return AddBoardCast(\"{0},{1}\")", Eval("BC_ID"),"Edit") %>'>
</td>
<td id="trRPTL" runat="server" align="center">
<asp:Label ID="lblUName" runat="server" ForeColor="Red" Text='<%#Eval("UserName")%>' />
</td>
<td align="center">
<asp:Label ID="lblRoleName" runat="server" ForeColor="Black" Text='<%#Eval("RoleName")%>' />
</td>
<td align="center">
<asp:Label ID="lblToDate" runat="server" ForeColor="Black"><%#DataBinder.Eval(Container.DataItem, "BC_FromDate", "{0:dd/MM/yyyy}")%></asp:Label>
</td>
<td align="center"><asp:Label ID="lblFromDate" runat="server" ForeColor="Black"><%#DataBinder.Eval(Container.DataItem, "BC_TODate", "{0:dd/MM/yyyy}")%></asp:Label></td>
<td align="center" width="20%">
<div style="color: black"><%#Eval("BC_Comment")%></div>
</td>
<td align="center">
<asp:HiddenField ID="hdnBC_ID" runat="server" Value='<%#Eval("BC_ID") %>' />
<asp:HiddenField ID="hdnUserID" runat="server" Value='<%#Eval("UserID") %>' />
<asp:RadioButtonList ID="rdStatus" runat="server" Height="48px" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="rdStatus_SelectedIndexChanged" CssClass="rad">
<asp:ListItem Text="Active" Value="1"></asp:ListItem>
<asp:ListItem Text="Deactive" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ContentTemplate>
</asp:UpdatePanel>

RequiredFieldValidator for dropdownlist not work

what I do wrong?
<asp:Panel ID="pnlProductUnits" runat="server" Width="100%">
<asp:Repeater ID="repProductUnits" runat="server" EnableViewState="true" onitemcommand="Button_ItemCommand">
<HeaderTemplate>
<table class="grid" width="100%">
<tbody>
<tr>
<th align="left">test1</th>
<th align="left">test2</th>
<th align="left">test3</th>
<th width="50"></th>
</tr>
</tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# ((DBData.Catalog.ProductU)Container.DataItem).PrimaryUnitName%>
</td>
<td align="center">
<%# ((DBData.Catalog.ProductU)Container.DataItem).SecondaryUnitName%>
</td>
<td align="center">
<%# ((DBData.Catalog.ProductU)Container.DataItem).Quantity%>
</td>
<td style="display:none">
<asp:Label ID="PrimaryUnitID" runat="server"
Text="<%# ((DBData.Catalog.ProductU)Container.DataItem).PrimaryUnitID%>">
</asp:Label>
<asp:Label ID="SecondaryUnitID" runat="server"
Text="<%# ((DBData.Catalog.ProductU)Container.DataItem).SecondaryUnitID%>">
</asp:Label>
</td>
<td align="center">
<asp:Button id="btRemove" runat="server" commandname="deleteProductUnit" Text="Delete">
</asp:Button>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:DropDownList ID="ddlPrimaryUnit" runat="server" ValidationGroup="grpQuantity">
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ErrorMessage="*"
Display="Dynamic" Text="*" ControlToValidate="ddlPrimaryUnit" ValidationGroup="grpQuantity" ForeColor="#FF3300">
</asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlSecondaryUnit" runat="server" ValidationGroup="grpQuantity">
</asp:DropDownList>
<asp:RequiredFieldValidator runat="server" ErrorMessage="*" Display="Dynamic" Text="*" ControlToValidate="ddlSecondaryUnit" ValidationGroup="grpQuantity" ForeColor="#FF3300"></asp:RequiredFieldValidator>
</td>
<td>
<asp:TextBox ID="txtQuantity" runat="server" placeholder="select value" ClientIDMode="Static"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="txtQuantity" ValidationGroup="grpQuantity" ForeColor="#FF3300"></asp:RequiredFieldValidator>
</td>
<td colspan="20">
<asp:Button id="btNew" runat="server" commandname="addProductUnit" Text="Add"
CommandArgument="test" ValidationGroup="grpQuantity"> </asp:Button>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
I suspect your problem is related to the validator knowing what the DropDownList's original selection was and whether or not something has been selected. You may need to add an InitialValue to the required field validator.
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ErrorMessage="*" Display="Dynamic" Text="*"
ControlToValidate="ddlSecondaryUnit" ValidationGroup="grpQuantity"
ForeColor="#FF3300" InitialValue=""></asp:RequiredFieldValidator>
Depending on your DropDownList's datasource, that value may be something like "Please Select" or maybe just blank.

File Uploader not working wnen used in ajax tab container with update panel

I am using ajax tab container with update panel and file uploader
fileuploaderId.HasFille always blank.
Here is my html code
<cc1:TabPanel ID="tour" runat="server">
<HeaderTemplate>
<span class="label_Tag_big">भ्रमण (Tours)</span></HeaderTemplate>
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center class="control_bg">
<table width="75%" cellspacing="1">
<tr>
<td style="background-color: #996666">
<table width="100%" align="center" cellpadding="0" cellspacing="1">
<tr class="form_heading">
<td colspan="2">
<asp:Label ID="lbl" runat="server" Text="भ्रमण (Tours)"></asp:Label>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
विभागाध्‍यक्ष / अधिकारी का पद नाम
</td>
<td>
designation location, department
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblCurrentTT" runat="server"></asp:Label>
का लक्ष्‍य
</td>
<td>
<asp:Label ID="lblTargetT" runat="server"></asp:Label>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblCurrentTA" runat="server"></asp:Label>
की लक्ष्‍य प्राप्ति
</td>
<td>
<asp:Label ID="lblAchivedT" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="form_sub_heading" colspan="2" align="left">
भ्रमण का विवरण (Tours details)
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td width="45%">
दौरे का स्थान
</td>
<td width="55%">
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<td width="50%">
<asp:DropDownList ID="ddlLocLevel" runat="server" OnSelectedIndexChanged="ddlLocLevel_SelectedIndexChanged"
AutoPostBack="True" Width="200px" />
<asp:RequiredFieldValidator ID="rfqLocLevel" runat="server" InitialValue="0" ControlToValidate="ddlLocLevel"
Display="None" ErrorMessage="दौरे का स्थान चुनें " ValidationGroup="tour"></asp:RequiredFieldValidator>
</td>
<td width="50%">
<asp:DropDownList ID="ddlLocation" runat="server" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged"
AutoPostBack="True" Width="200px">
<asp:ListItem Text="-- चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqLocation" runat="server" InitialValue="0" ControlToValidate="ddlLocation"
Display="None" ErrorMessage="-- चुनें --" ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddlSubDistrict" runat="server" OnSelectedIndexChanged="ddlSubDistrict_SelectedIndexChanged"
AutoPostBack="True" Width="200px">
<asp:ListItem Text="-- तहसील चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqddlSubDistrict" runat="server" InitialValue="0"
ControlToValidate="ddlSubDistrict" Display="None" ErrorMessage="-- चुनें --"
ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlPoliceStation" runat="server" Width="200px">
<asp:ListItem Text="-- पुलिस थाना चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqddlPoliceStation" runat="server" InitialValue="0"
ControlToValidate="ddlPoliceStation" Display="None" ErrorMessage="-- पुलिस थाना चुनें --"
ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblTourStartDate" runat="server" Text="दौरे की तिथि "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtTourStartDate" runat="server" Width="25%" CssClass="date" onkeypress="return false;"
onPaste="return false;"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtTourStartDate"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTourStartDate"
ErrorMessage="दौरे की आरम्भिक तिथि डाले" ValidationGroup="tour" Display="None"></asp:RequiredFieldValidator>
से
<asp:TextBox ID="txtTourEndDate" runat="server" Width="25%" onkeypress="return false;"
onPaste="return false;"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtTourEndDate"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>
तक
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTourEndDate"
ErrorMessage="दौरे की समाप्ति तिथि डाले" ValidationGroup="tour" Display="None"></asp:RequiredFieldValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
दौरे के दौरान निरीक्षण किया गया ?
</td>
<td>
<asp:RadioButtonList ID="rdbtnInsp" runat="server" RepeatDirection="Horizontal" AutoPostBack="true"
OnSelectedIndexChanged="rdbtnInsp_SelectedIndexChanged">
<asp:ListItem Text="नही" Value="0"></asp:ListItem>
<asp:ListItem Text="हाँ" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
निरीक्षण नही किये जाने की स्थिति मे टिप्पणी
</td>
<td>
<asp:TextBox ID="txtConIns" runat="server" TextMode="MultiLine" MaxLength="4000"
Enabled="false" Rows="3" Width="97%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfqConIns" runat="server" ControlToValidate="txtConIns"
ValidationGroup="tour" ErrorMessage="निरीक्षण नही किये जाने की स्थिति मे टिप्पणी डाले "
Enabled="false" Display="None">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
दौरे के दौरान रात्री विश्राम किया गया ?
</td>
<td>
<asp:RadioButtonList ID="rdbtnNHault" runat="server" RepeatDirection="Horizontal"
AutoPostBack="true" OnSelectedIndexChanged="rdbtnNHault_SelectedIndexChanged">
<asp:ListItem Text="नही" Value="0"></asp:ListItem>
<asp:ListItem Text="हाँ" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
रात्री विश्राम नही किये जाने की स्थिति मे टिप्पणी
</td>
<td>
<asp:TextBox ID="txtConNHault" runat="server" TextMode="MultiLine" MaxLength="4000"
Enabled="false" Rows="3" Width="97%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfqConNHault" runat="server" ControlToValidate="txtConNHault"
Display="None" ValidationGroup="tour" ErrorMessage="रात्री विश्राम नही किये जाने की स्थिति मे टिप्पणी डाले "
Enabled="false">
</asp:RequiredFieldValidator>
<asp:ValidationSummary ID="vsTour" runat="server" ShowSummary="False" ShowMessageBox="true"
ValidationGroup="tour" />
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="Label8" runat="server" Text="संलग्न निरीक्षण रिपोर्ट "></asp:Label>
</td>
<td>
<asp:FileUpload ID="fuTourReport" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Only pdf file is allowed!"
ValidationExpression="^.+(.pdf|.PDF)$" ControlToValidate="fuTourReport" Display="None"
ValidationGroup="nhalt"> </asp:RegularExpressionValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td colspan="2" align="center">
<asp:Button ID="btnSaveTour" runat="server" Text="Submit" ValidationGroup="tour"
OnClick="btnSaveTour_Click" CssClass="savetour" />
<asp:Button ID="btnCancelTour" runat="server" Text="Cancel" CausesValidation="False" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<center style="padding-top: 5px">
<asp:GridView ID="grdTours" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="tourId" Width="100%" OnPageIndexChanging="grdTours_PageIndexChanging"
OnRowCommand="grdTours_RowCommand">
<Columns>
<asp:BoundField DataField="Location_NameH" HeaderText="दौरे का स्थान " />
<asp:BoundField DataField="tourStartDate" HeaderText="आरम्‍भिक तिथि" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="tourEndDate" HeaderText="समाप्‍ति की तिथि" DataFormatString="{0:dd/MM/yyyy}" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkinsdetail" runat="server" Text="Detail" CommandName="insdetail"
CommandArgument='<%#Eval("tourId")%>'></asp:LinkButton></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</center>
</center>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
I have already tried this
<Triggers>
<asp:PostBackTrigger ControlID="clickButton" />
</Triggers>
and
protected void Page_Init(object sender, EventArgs e)
{
PostBackTrigger trig = new PostBackTrigger();
trig.ControlID = btnSaveTour.UniqueID;
UpdatePanel1.Triggers.Add(trig);
}
but no luck ....
Unfortunately, the FileUpload control doesn't work inside an UpdatePanel
You don't have many options really other than removing the UpdatePanel or looking at working around it by using something like the AsyncFileUpload control
See this answer for some more detail
Dave

2 asp panel controls in an update panel

I kept 2 asp panel controls (with text boxes and buttons) in an update panel so that i want only 1 to be displayed at a time. And when i click on the button, the next asp panel should be visible with old asp panel hidden. I am not able to figure it out.. Here is the code...
<asp:UpdatePanel ID="updatepnlSSN" ChildrenAsTriggers="false" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlSSNLookup" runat="server" BackColor="#EEE6DF" BorderColor="#274F73"
BorderStyle="Outset">
<table>
<tr>
<td colspan="3">
<asp:Label ID="lblMsg" runat="server" ForeColor="#713C2C"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblStudentID" runat="server" Text="State Student ID:" ForeColor="#274F73" ToolTip="State Student ID Label"></asp:Label>
</td
<td>
<asp:TextBox ID="txtStudentID" runat="server" ToolTip="Enter the student's state ID number" AccessKey="i" TabIndex="1"></asp:TextBox>
</td>
<td>
<asp:RegularExpressionValidator ID="valStudentID" runat="server" ControlToValidate="txtStudentID" ErrorMessage="Please enter numeric only" ValidationExpression="[0-9]+" ForeColor="#713C2C" Display="Dynamic">
</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="valStdntID" runat="server" ControlToValidate="txtStudentID" Display="Dynamic" ErrorMessage="Please enter a State Student ID" ForeColor="#713C2C"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblFName" runat="server" Text="Student Legal First Name:" ForeColor="#274F73" ToolTip="First Name Label"></asp:Label>
<td>
<td>
<asp:TextBox ID="txtFName" runat="server" AccessKey="f" TabIndex="2" ToolTip="Enter the Student's First Name"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="valFirstName" runat="server" ControlToValidate="txtFName" Display="Dynamic" ErrorMessage="Please enter the student's first name." ForeColor="#713C2C"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDOB" runat="server" ForeColor="#274F73" Text="Student Date of Birth </br> (mm/dd/yyyy)" ToolTip="STudent's date of birth label"></asp:Label>
</td>
<td>
<div style="position: relative;">
<asp:TextBox ID="txtDOB" runat="server" AccessKey="d" TabIndex="3" ToolTip="Enter the student's date of birth"></asp:TextBox>
<cc1:CalendarExtender ID="txtDOB_CalendarExtender" runat="server" Enabled="True" TargetControlID="txtDOB" PopupPosition="Right" Format="MM/dd/yyyy">
</cc1:CalendarExtender>
</div>
</td>
<td>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtDOB" ErrorMessage="Please enter a valid date: mm/dd/yyyy" ForeColor="#713C2C" MaximumValue="01/01/2075" MinimumValue="01/01/1970" Type="Date" Display="Dynamic"></asp:RangeValidator>
<asp:RequiredFieldValidator ID="valStudentDOB" runat="server" ControlToValidate="txtDOB" Display="Dynamic" ErrorMessage="Please enter the student's date of birth" ForeColor="#713C2C"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSearchSSN" runat="server" Text="Search" AccessKey="s" TabIndex="4" ToolTip="Begin student search" />
</td>
</tr>
</table>
</asp:Panel>
</td> </tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="padding: 0 10px 0 10px">
<asp:Panel ID="pnlSSNEntry" runat="server" BackColor="#EEE6DF" BorderColor="#274F73" BorderStyle="Outset" Visible="False" Height="110px">
<table align="left">
<tr>
<td colspan="3">
<asp:Label ID="lblSSnText" runat="server" ForeColor="#274F73" Text="Please enter the SSN for: "></asp:Label>
<asp:Label ID="lblSSNName" runat="server" ForeColor="#274F73"></asp:Label>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblSSNSubmitMsg" runat="server" ForeColor="#713C2C"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblSSN0" runat="server" ForeColor="#274F73" Text="Social Security Number: "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtArea" runat="server" AccessKey="a" MaxLength="3" TabIndex="5" ToolTip="Enter the student's SSN area number" Width="29px"></asp:TextBox>
<asp:TextBox ID="txtGroup" runat="server" AccessKey="g" MaxLength="2" TabIndex="6" ToolTip="Enter the student's SSN group number" Width="22px"></asp:TextBox>
<asp:TextBox ID="txtSerial" runat="server" AccessKey="r" MaxLength="4" TabIndex="7" ToolTip="Enter the student's SSN serial number" Width="35px"></asp:TextBox>
</td>
<td>
<asp:Label ID="lblSSNError" runat="server" ForeColor="#713C2C" Text="Please enter a valid Social Security Number" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSSN" runat="server" Text="Submit SSN" AccessKey="n" TabIndex="8" ToolTip="Submit the student's SSN" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearchSSN" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnSSN" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Would you not be better using an ASP:MultiView. Then you show one view at a time and it come with mutually exclusive bindings associated with it.
<asp:MultiView>
<asp:View>
View 1
</asp:View>
<asp:View>
View 2
</asp:View>
</asp:MultiView>
You would be better off using MultiView inside UpdatePanel and setting ActiveView based on button click. Here's a tutorial
In short MultiView is a wrapper around panels. It contains collection of View objects that can be activated. Only one View can be visible at any given time.
Answers above suggested an excellent approach to solve above issue, but if you really want to do that than try adding code on button click events like
protected void btnSearchSSN_Click(object sender, EventArgs e)
{
pnlSSNLookup.Visible = false;
this.pnlSSNEntry.Visible = true;
}
protected void btnSSN_Click(object sender, EventArgs e)
{
pnlSSNEntry.Visible = false;
this.pnlSSNLookup.Visible = true;
}
Hopefully it will give you required result you looking for.

Calendar extender in modal popup extender ASP.NET not working

I'm using a calendar extender in a panel which popup using modalpopup extender, so panel is poped up contains the calendar extender but the calendar is behind every thing, i tried to change the z-index but all in vain, seems to me that it is a bug in the ASP.net AjaxToolKit.Any one has an idea about this problem and if it can be solved?
Edit:
<style type="text/css">
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.2;
}
.ob_show_panelsholder
{
border: 1px solid #736F6E;
}
.enterzipCalenderCompliant {
PADDING-RIGHT: 10px; FLOAT: left /*No display=inline*/
}
.ajax__calendar_container { z-index : 1000 ; }
</style>
<script type="text/javascript">
function calendarShown(sender, args) {
sender.style.zIndex = 10005;
}
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="_pnlShowPersonalData" runat="server">
<table class="style1">
<tr>
<td>
<asp:Image ID="_imgCurrentPP" runat="server" Height="100px" Width="100px" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="First name :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblFirstName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Last name :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblLastName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="BirthDate :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblBirthDate" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label10" runat="server" Text="Mobile number :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblMobileNumber" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label12" runat="server" Text="Location :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblLocation" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label13" runat="server" Text="Gender :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblGender" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="_btnEditPersonalData" runat="server" Text="Edit Profile" />
<asp:ModalPopupExtender ID="_btnEditPersonalData_ModalPopupExtender" runat="server"
DynamicServicePath="" Enabled="True" TargetControlID="_btnEditPersonalData" BackgroundCssClass="modalBackground"
PopupControlID="_pnlEditPersonalData" CancelControlID="_btnCancel">
</asp:ModalPopupExtender>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="_pnlEditPersonalData" runat="server">
<table>
<tr>
<td>
<asp:Label ID="_FirstName" runat="server" Text="First name :" ></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtFirstName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_LastName" runat="server" Text="Last name :"></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtLastName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_BirthDate" runat="server" Text="Birth date :"></asp:Label>
</td>
<td class="ajax__calendar_container">
<asp:TextBox ID="_txtBirthDate" runat="server"></asp:TextBox>
<asp:MaskedEditExtender ID="_txtBirthDate_MaskedEditExtender" runat="server" Enabled="True"
TargetControlID="_txtBirthDate" MaskType="Date" ErrorTooltipEnabled="True" MessageValidatorTip="true"
Mask="99/99/9999">
</asp:MaskedEditExtender>
<div>
<asp:CalendarExtender ID="_txtBirthDate_CalendarExtender" runat="server" Enabled="True"
PopupButtonID="_btnCalendar" TargetControlID="_txtBirthDate">
</asp:CalendarExtender>
</div>
<asp:ImageButton ID="_btnCalendar" runat="server" ImageUrl="~/Images/calendar_button_b.jpg" />
<%-- <img alt="Icon" src="~/Images/calendar_button_b.jpg" id="Image1" />--%>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_ProfilePic" runat="server" Text="Profile picture :"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="FileUpload1"--%><%-- ErrorMessage="*" ValidationGroup="signup"></asp:RequiredFieldValidator>--%>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.png|.jpg)$"
ControlToValidate="FileUpload1" ErrorMessage="Please Select Png or Jpg File"
ValidationGroup="UploadFile"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_MobileNumber" runat="server" Text="Mobile number :"></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtMobileNumber" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_Password" runat="server" Text="Password :"></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtPassword" runat="server"></asp:TextBox>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="_pnlLocation" runat="server">
<table width="21%">
<tr>
<td>
<asp:Label ID="_Country" runat="server" Text="Country :"></asp:Label>
</td>
<td>
<uc1:CountryListUC ID="CountryListUC1" runat="server" EnablePostBack="True" EnableValidation="False"
OnListIndexChanged="CountrySelectedIndexChanged" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="_Governet" runat="server" Text="Governet:"></asp:Label>
</td>
<td>
<uc2:GovernateListUC ID="GovernateListUC1" runat="server" OnListIndexChanged="GovernateSelectedIndexChanged"
Enabled="False" EnablePostBack="True" EnableValidation="False" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="_District" runat="server" Text="District :"></asp:Label>
</td>
<td>
<uc3:DistrictListUC ID="DistrictListUC1" runat="server" Enabled="False" EnablePostBack="True"
EnableValidation="False" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CountryListUC1" EventName="ListIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<table width="22%">
<tr>
<td>
<asp:Label ID="_Gender" runat="server" Text="Gender :"></asp:Label>
</td>
<td>
<asp:DropDownList ID="_ddlGender" runat="server">
<asp:ListItem Value="1">Male</asp:ListItem>
<asp:ListItem Value="2">Female</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="_btnSaveChanges" runat="server" OnClick="_btnSaveChages_Click" Text="Save changes"
ValidationGroup="signup" />
</td>
<td valign="bottom">
<asp:Button ID="_btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
is the calendar extender an ajax extender or did you mean the asp calendar control? Either way I've tried both in your same situation described and it works. Try posting some code you are using so we can see where the issue lies and be of further assistance.
Edit: here's the code I used from yours. I took out the usercontrols so I could debug the page and it seemed to work. Here's an a screenshot
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="web.test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.2;
}
.ob_show_panelsholder
{
border: 1px solid #736F6E;
}
.enterzipCalenderCompliant {
PADDING-RIGHT: 10px; FLOAT: left /*No display=inline*/
}
.ajax__calendar_container { z-index : 1000 ; }
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="smtest" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="_pnlShowPersonalData" runat="server">
<table class="style1">
<tr>
<td>
<asp:Image ID="_imgCurrentPP" runat="server" Height="100px" Width="100px" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="First name :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblFirstName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Last name :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblLastName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="BirthDate :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblBirthDate" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label10" runat="server" Text="Mobile number :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblMobileNumber" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label12" runat="server" Text="Location :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblLocation" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label13" runat="server" Text="Gender :"></asp:Label>
</td>
<td>
<asp:Label ID="_lblGender" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="_btnEditPersonalData" runat="server" Text="Edit Profile" />
<ajaxToolkit:ModalPopupExtender ID="_btnEditPersonalData_ModalPopupExtender" runat="server" TargetControlID="_btnEditPersonalData" BackgroundCssClass="modalBackground" PopupControlID="_pnlEditPersonalData" CancelControlID="_btnCancel" />
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="_pnlEditPersonalData" runat="server">
<table>
<tr>
<td>
<asp:Label ID="_FirstName" runat="server" Text="First name :" ></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtFirstName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_LastName" runat="server" Text="Last name :"></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtLastName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_BirthDate" runat="server" Text="Birth date :"></asp:Label>
</td>
<td class="ajax__calendar_container">
<asp:TextBox ID="_txtBirthDate" runat="server"></asp:TextBox>
<ajaxtoolkit:MaskedEditExtender ID="_txtBirthDate_MaskedEditExtender" runat="server" Enabled="True"
TargetControlID="_txtBirthDate" MaskType="Date" ErrorTooltipEnabled="True" MessageValidatorTip="true"
Mask="99/99/9999">
</ajaxtoolkit:MaskedEditExtender>
<div>
<ajaxtoolkit:CalendarExtender ID="_txtBirthDate_CalendarExtender" runat="server" Enabled="True"
PopupButtonID="_btnCalendar" TargetControlID="_txtBirthDate">
</ajaxtoolkit:CalendarExtender>
</div>
<asp:ImageButton ID="_btnCalendar" runat="server" ImageUrl="~/Images/calendar_button_b.jpg" />
<%-- <img alt="Icon" src="~/Images/calendar_button_b.jpg" id="Image1" />--%>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_ProfilePic" runat="server" Text="Profile picture :"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="Label1" runat="server"></asp:Label>
<%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="FileUpload1"--%><%-- ErrorMessage="*" ValidationGroup="signup"></asp:RequiredFieldValidator>--%>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.png|.jpg)$"
ControlToValidate="FileUpload1" ErrorMessage="Please Select Png or Jpg File"
ValidationGroup="UploadFile"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_MobileNumber" runat="server" Text="Mobile number :"></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtMobileNumber" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_Password" runat="server" Text="Password :"></asp:Label>
</td>
<td>
<asp:TextBox ID="_txtPassword" runat="server"></asp:TextBox>
</td>
</tr>
</table>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="_pnlLocation" runat="server">
<table width="21%">
<tr>
<td>
<asp:Label ID="_Country" runat="server" Text="Country :"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_Governet" runat="server" Text="Governet:"></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="_District" runat="server" Text="District :"></asp:Label>
</td>
<td>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
<table width="22%">
<tr>
<td>
<asp:Label ID="_Gender" runat="server" Text="Gender :"></asp:Label>
</td>
<td>
<asp:DropDownList ID="_ddlGender" runat="server">
<asp:ListItem Value="1">Male</asp:ListItem>
<asp:ListItem Value="2">Female</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="_btnSaveChanges" runat="server" Text="Save changes"
ValidationGroup="signup" />
</td>
<td valign="bottom">
<asp:Button ID="_btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
CSS solution that worked for me:
.ajax__calendar_container
{
position :absolute;
z-index : 100003 !important;
}
Make sure to use !important declaration. Without it z-index was always overwrited by higher settings. You should also check z-index in css for popup dialog and it's background.

Resources