Modalpopup wont close when dropdown is selected - asp.net

I've been having this odd issue with modal popups. For some reason when I choose a dropdown item my update button wont fire a click event. but then I leave the dropdown at their default values the update button works just fine.
here's my aspx page code
<asp:Button ID="Button1" CssClass="hide" runat="server" Text="Button" />
<ajaxToolkit:ModalPopupExtender runat="server" ID="cfPopUp" PopupControlID="Panel4"
TargetControlID="Button1" OkControlID="cfUpdateBtn" CancelControlID="cfCancelBtn" />
<asp:Panel ID="Panel4" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="UpdatePanel2" runat="Server">
<ContentTemplate>
<asp:Panel ID="Panel13" CssClass="" runat="server">
<asp:Panel ID="Panel14" CssClass="" runat="server">
<div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
<asp:Label ID="Label25" Width="200px" runat="server" Text="Health and Safety Net" /><div
class="seperator">
</div>
<table class="style143">
<tr>
<td class="style185">
<asp:Label ID="cfCategorylbl" runat="server" Text="Category:"></asp:Label>:
</td>
<td>
<asp:DropDownList ID="cbFactors_Categories" runat="server" Width="350px" Font-Names="Tahoma"
Font-Size="Small" ForeColor="DimGray" Height="24px" CssClass="style75">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="cbFactors_Categories"
Category="categories" ServiceMethod="getCategory" ServicePath="~/2012/IrSubmitWebService.asmx"
PromptText="Select Category" />
</td>
<td align="center" rowspan="3" valign="top">
<asp:Label ID="lblFactor_ID" runat="server" Font-Names="Tahoma" Font-Size="Small"
ForeColor="DimGray" Style="font-style: italic" TabIndex="56"></asp:Label>
<cc1:DynamicPopulateExtender ID="lblFactor_ID_DynamicPopulateExtender" runat="server"
Enabled="True" TargetControlID="lblFactor_ID" BehaviorID="dp1" ServiceMethod="getFactorID"
ServicePath="~/2012/IrSubmitWebService.asmx">
</cc1:DynamicPopulateExtender>
<hr class="style157" />
<asp:Label ID="cfID" runat="server" Font-Names="Tahoma" Font-Size="Small" ForeColor="DimGray"
Style="font-style: italic" Width="400px" TabIndex="57"></asp:Label>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label ID="cfTypeslbl" runat="server" Text="Type:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cbFactors_Types" runat="server" ForeColor="DimGray" Height="24px"
TabIndex="54" Width="350px" Font-Names="Tahoma" Font-Size="Small" CssClass="style75">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cbFactors_Types_CascadingDropDown" runat="server"
TargetControlID="cbFactors_Types" ParentControlID="cbFactors_Categories" Category="type"
ServiceMethod="getTypeofAction" ServicePath="~/2012/IrSubmitWebService.asmx"
PromptText="Select Type">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label ID="cfFactorslbl" runat="server" Text="Factor:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cbFactors_Factors" runat="server" ForeColor="DimGray" Height="24px"
TabIndex="55" Width="350px" Font-Names="tahoma" Font-Size="Small" CssClass="style75">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cbFactors_Factors_CascadingDropDown" runat="server"
TargetControlID="cbFactors_Factors" ParentControlID="cbFactors_Types" Category="category"
ServiceMethod="getFactor" ServicePath="~/2012/IrSubmitWebService.asmx" PromptText="Select Factor">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label Text="Justification:" ID="cfJustificationlbl" runat="server"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="29px"
Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
ToolTip="Provide a justification for this factor." Width="775px" Font-Names="Tahoma"
Font-Size="Small"></asp:TextBox>
</td>
</tr>
</table>
<br />
<div style="text-align: center">
<asp:Button CausesValidation="false" ID="cfUpdateBtn" runat="server"
Text="Update" CssClass="button" /><span style="margin-left: 10px"><asp:Button CausesValidation="false"
ID="cfCancelBtn" runat="server" Text="Cancel" CssClass="button" /></span></div>
</div>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
and my code behind for my update (it just closes the popup)
Protected Sub cfUpdateBtn_Click(sender As Object, e As EventArgs) Handles cfUpdateBtn.Click
cfPopUp.Hide()
End Sub
For the life of me I can't figure out why the update button wont work when the dropdowns are not the default value.
Thanks for your help guys

The possible reason may be you are binding your dropdownlist with a webservice. Whenever you click to an item on dropdownlist webservice may be called. If webservice is called then may be your page again loaded ? I don't know the exact reason why it is not working. You have to check the service behavior what happened when the service is called.

I basically rebuilt my modal popup and update panel like so
<asp:Panel ID="pnlEditPopup" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlEditPopupContent" runat="server">
<div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
<table cellpadding="0" cellspacing="4" border="0">
<tr>
<td class="name">Category:</td>
<td class="value">
<asp:DropDownList id="ddCat" runat="server">
<asp:listitem value="">No Selection</asp:listitem>
<asp:listitem value="Action">Action</asp:listitem>
<asp:listitem value="Worksite">Worksite</asp:listitem>
<asp:listitem value="Human Factors">Human Factors</asp:listitem>
<asp:listitem value="System Factors">System Factors</asp:listitem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="name">Type:</td>
<td class="value">
<asp:DropDownList id="ddType" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccType" runat="server"
TargetControlID="ddType"
ParentControlID="ddCat"
PromptText="No Selection"
LoadingText="Please Wait..."
ServicePath="~/2012/IrSubmitWebService.asmx"
ServiceMethod="getTypeofAction"
Category="Other"
/>
</td>
</tr>
<tr>
<td class="name">Factor:</td>
<td class="value">
<asp:DropDownList id="ddfactor" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccFactor" runat="server"
TargetControlID="ddfactor"
ParentControlID="ddType"
PromptText="No Selection"
LoadingText="Please Wait..."
ServicePath="~/2012/IrSubmitWebService.asmx"
ServiceMethod="getFactor"
Category="Other"
/>
</td>
</tr>
<tr>
<td>
Justification:
<asp:Label ID="factorID" runat="server" Visible="false"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="100px"
Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
ToolTip="Provide a justification for this factor." Width="300px" Font-Names="Tahoma"
Font-Size="Small"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Factor ID<br />
and Description:
</td>
<td>
<asp:Label ID="factor_id_Desc" runat="server" Width="300px" Font-Names="Tahoma" Font-Size="Small"
ForeColor="DimGray" TabIndex="56"></asp:Label>
<cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server"
Enabled="True" TargetControlID="factor_id_Desc" BehaviorID="dp1" ServiceMethod="getFactorID"
ServicePath="~/2012/IrSubmitWebService.asmx">
</cc1:DynamicPopulateExtender>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnOkEditPopup" runat="server" Text="Ok" CssClass="button"/>
<span style="margin-left:10px"><asp:button id="btnCancelEditPopup" runat="server" text="Cancel" CssClass="button"/></span>
</td>
</tr>
</table>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="mpeEdit" runat="server"
TargetControlID="btnOpenEditPopup"
PopupControlID="pnlEditPopup"
/>
Fixed my issue. I still dont know why it wasn't working when I asked the question but I was able to solve it. Thanks to all who looked into it for me.

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>

Server side events not firing the first time when asp validator used into the page

I am created a page with update panel and used Asp.net validation controls to be
validated the page is making an issue is "i am straightly going to submit the page
and page gets validated properly then, i am going to click/select any controls on
the page is not get post back"
The below code i am used
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div id="divMyDataManualEntry" runat="server">
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<td style="width: 5%;" valign="top">
<asp:Label ID="lblGeo" Font-Bold="true" runat="server" Text="Geography"></asp:Label><span
class="redtext">*</span>
</td>
<td valign="top" style="width: 15%">
<asp:DropDownList ID="ddlgeo" TabIndex="1" runat="server" CssClass="textbox" Width="100%"
OnSelectedIndexChanged="ddlgeo_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlgeo"
ValidationGroup="Submit" InitialValue="-1" ErrorMessage="Select Geography"></asp:RequiredFieldValidator>
</td>
</tr> </table>
<table width="100%" id="BtnContainer" runat="server">
<tr>
<td align="center">
<asp:Button ID="btnSubmit" runat="server" OnClientClick="javascript:return IsValidated();"
ValidationGroup="Submit" CssClass="Keybutton" TabIndex="14" Text="Submit" OnClick="btnSubmit_Click" />
<asp:Button ID="btnreset" runat="server" Text="Reset" CssClass="Keybutton" TabIndex="15"
OnClick="btnReset_click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

Second button Event is not happening in Update panel in aspx page

I have a aspx page in which i have putted two update panel with two submit buttons one in each...But on clicking second button it is not firing second button event it is taking first button validate message..
Here is my aspx page code....
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="updDate1" runat="server" UpdateMode="Conditional" style="position: absolute;
left: 0px; top: 0px; width: 339px; height: 243px;">
<ContentTemplate>
<table width="400">
<tr>
<td>
</td>
<td colspan="2">
<b>Sign Up for New User Account</b>
</td>
</tr>
<tr>
<td>
UserName:
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server" />
</td>
<td>
<asp:RequiredFieldValidator ID="rqfUserName" runat="server" ControlToValidate="txtUserName"
Display="Dynamic" ErrorMessage="Required" ForeColor="Red" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="txtPwd" runat="server" TextMode="Password" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPwd"
Display="Dynamic" ErrorMessage="Required" ForeColor="Red" />
</td>
</tr>
<tr>
<td>
Confirm Password:
</td>
<td>
<asp:TextBox ID="txtCnfPwd" runat="server" TextMode="Password" />
</td>
<td>
<asp:RequiredFieldValidator ID="PasswordConfirmRequiredValidator" runat="server"
ControlToValidate="txtCnfPwd" ForeColor="red" Display="Dynamic" ErrorMessage="Required" />
<asp:CompareValidator ID="PasswordConfirmCompareValidator" runat="server" ControlToValidate="txtCnfPwd"
ForeColor="red" Display="Dynamic" ControlToCompare="txtPwd" ErrorMessage="Confirm password must match password." />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Create User" />
</td>
<tr>
<td class="style1" colspan="3">
<asp:Label ID="lblResult" runat="server" Font-Bold="true" />
</td>
</tr>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<div>
<asp:UpdatePanel ID="updDate2" runat="server" UpdateMode="Conditional" RenderMode="Inline"
style="position: absolute; left: 628px; top: 0px; width: 339px; height: 243px;">
<ContentTemplate>
<div class="GridviewDiv">
<table>
<tr>
<td align="right">
</td>
</tr>
<tr>
<td>
<asp:GridView ID="gvRoles" runat="server" CssClass="Gridview" AutoGenerateColumns="false">
<HeaderStyle BackColor="#df5015" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkRole" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Role Name">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text="<%#Container.DataItem %>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnAssign" runat="server" Text="Assign or UnAssign" OnClick="btnAssign_Click"
Style="height: 26px" />
</td>
</tr>
</table>
<div>
<asp:Label ID="lblSuccess" runat="server" Font-Bold="true" />
<br />
<asp:Label ID="lblError" runat="server" Font-Bold="true" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
Any help will be highly apprecited..
Thanks In advance..
Dear i tried your code by Making dummy project and it clearly tells me that it's a problem of CausesValidation="false",I know you tried this thing as well but even i don't know your back end coding.So same suggesstion from my side just change your btnAssign like
<asp:Button ID="btnAssign" runat="server" Text="Assign or UnAssign"
Style="height: 26px" onclick="btnAssign_Click" CausesValidation="false" />
Note :- Try to check it in different browser as well.
Also try for ValidationGroup as well.
Apply ValidationGroup property into your validation control and also assign that same property to btnSubmit.This will work.
Hope it works.
Set CausesValidation="false" in the second button
Setting CausesValidation="false" in the second button should have worked.
One another way to get this work is to assign a common ValidationGroup to your Validators as well as to your first Submit button [only of UpdatePanel updDate1 ].
For e.g. in your Validators:
<asp:RequiredFieldValidator ID="rqfUserName" runat="server"
ControlToValidate="txtUserName"Display="Dynamic"
ErrorMessage="Required" ForeColor="Red"
ValidationGroup="updDate1UserCreation" />
And your submit button with ID:btnSubmit
<asp:Button ID="btnSubmit" runat="server"
OnClick="btnSubmit_Click" Text="Create User"
ValidationGroup="updDate1UserCreation" />
Your first updatePanel will finally look like:
<asp:UpdatePanel ID="updDate1" runat="server" UpdateMode="Conditional"
style="position: absolute;
left: 0px; top: 0px; width: 339px; height: 243px;">
<ContentTemplate>
<table width="400">
<tr>
<td>
</td>
<td colspan="2">
<b>Sign Up for New User Account</b>
</td>
</tr>
<tr>
<td>
UserName:
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server" />
</td>
<td>
<asp:RequiredFieldValidator ID="rqfUserName" runat="server"
ControlToValidate="txtUserName"
Display="Dynamic" ErrorMessage="Required" ForeColor="Red"
ValidationGroup="updDate1UserCreation" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="txtPwd" runat="server" TextMode="Password" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="txtPwd"
Display="Dynamic" ErrorMessage="Required" ForeColor="Red"
ValidationGroup="updDate1UserCreation" />
</td>
</tr>
<tr>
<td>
Confirm Password:
</td>
<td>
<asp:TextBox ID="txtCnfPwd" runat="server" TextMode="Password" />
</td>
<td>
<asp:RequiredFieldValidator ID="PasswordConfirmRequiredValidator"
runat="server"
ControlToValidate="txtCnfPwd" ForeColor="red"
Display="Dynamic" ErrorMessage="Required"
ValidationGroup="updDate1UserCreation" />
<asp:CompareValidator ID="PasswordConfirmCompareValidator"
runat="server" ControlToValidate="txtCnfPwd"
ForeColor="red" Display="Dynamic" ControlToCompare="txtPwd"
ErrorMessage="Confirm password must match password."
ValidationGroup="updDate1UserCreation" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmit" runat="server"
OnClick="btnSubmit_Click" Text="Create User"
ValidationGroup="updDate1UserCreation" />
</td>
<tr>
<td class="style1" colspan="3">
<asp:Label ID="lblResult" runat="server" Font-Bold="true" />
</td>
</tr>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

Every time button cause full post back, even it is in update panel

In my code every DropDownList is inside an Update Panel and they're not postbacking. For each button click full postback occurs, but my buttons are in Update Panel. I tried using the asynpostback trigger, in that case server side message is not displayed. I want that message also.
My code is:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<table align="center" style="border: thin solid #FF0000" width="80%">
<tr>
<th colspan="2" align="center" bgcolor="Black" style="color: #FFFFFF">
Schedule New Batch
</th>
</tr>
<tr>
<td colspan="2" align="center">
<div>
<asp:Label ID="lblError" runat="server" Style="font-weight: 700; color: #FF0000;"
Text="Label" Visible="False"></asp:Label>
<asp:Label ID="lblSucess" runat="server" Style="font-weight: 700; color: #006600;
background-color: #FFFFFF;" Text="Label" Visible="False"></asp:Label>
</div>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td class="style44" align="right">
Technology<span class="style23">*</span> :
</td>
<td class="style45">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlTechnology" runat="server" Width="155px" Class="valid" OnSelectedIndexChanged="ddlTechnology_SelectedIndexChanged"
AutoPostBack="True" Height="23px">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style49" align="right">
Courses<span class="style23">*</span> :
</td>
<td class="style50">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlCourse" runat="server" Width="155px" Class="valid" OnSelectedIndexChanged="ddlCourse_SelectedIndexChanged"
AutoPostBack="True" Height="23px">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style9" align="right">
Faculty<span class="style23">*</span> :
</td>
<td class="style47">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlFaculty" runat="server" Width="155px" Class="valid" OnSelectedIndexChanged="ddlFaculty_SelectedIndexChanged"
AutoPostBack="True" Height="23px">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style44" align="right">
Timing<span class="style24">*</span> :
</td>
<td class="style45">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlTiming" runat="server" Width="155px" Height="23px" AutoPostBack="True"
Class="valid" OnSelectedIndexChanged="ddlTiming_SelectedIndexChanged">
</asp:DropDownList>
<asp:Button ID="btnAdd" runat="server" Text="Add" />
<cc1:modalpopupextender id="btnAdd_ModalPopupExtender" runat="server" cancelcontrolid="btnCancleInsertTime"
dynamicservicepath="" enabled="True" popupcontrolid="Panel1" targetcontrolid="btnAdd">
</cc1:modalpopupextender>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style44" align="right">
Start Date<span class="style23">*</span> :
</td>
<td class="style45">
<asp:UpdatePanel ID="UpdatePanel6" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtInsertdate" runat="server" Width="150px" Height="16px" Class="valid"></asp:TextBox>
<cc1:calendarextender id="CalendarExtender1" runat="server" targetcontrolid="txtInsertdate"
format="yyyy-MM-dd">
</cc1:calendarextender>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style51">
</td>
<td class="style45">
</td>
</tr>
<tr>
<td>
<div style="text-align: right">
<asp:Button ID="btnSchedule" runat="server" Text="Schedule" Style="font-weight: 700;
margin-left: 0px;" Width="81px" Height="24px" OnClick="btnSchedule_Click" />
</div>
</td>
<td>
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
<ContentTemplate>
<asp:Button ID="btnreset" runat="server" OnClick="btnreset_Click" Style="font-weight: 700"
Text="Reset" Width="67px" CausesValidation="False" UseSubmitBehavior="false" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnreset" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Panel ID="Panel1" runat="server" aline="center">
<table style="border: thin solid #FF0000; background: #7F8778">
<tr>
<th class="style53">
Please Add a Time
</th>
</tr>
<tr>
<td align="center" style="color: #FF0000" class="style53">
<asp:TextBox ID="txtInsertTime" runat="server" Width="124px"></asp:TextBox>
EX: 09:15AM
</td>
</tr>
<tr>
<asp:UpdatePanel ID="UpdatePanel7" runat="server">
<ContentTemplate>
<td align="center" class="style53">
<asp:Button ID="btnInsertTime" runat="server" Text="Add Time" Width="73px" OnClientClick="return InsertTime()"
OnClick="btnInsertTime_Click" class="cancel" />
<asp:Button ID="btnCancleInsertTime" Text="Cancel" Width="55px" runat="server" class="cancel" />
</td>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
</table>
</asp:Panel>
</td>
</tr>
</table>
<br />
</form>
</asp:Content>
I've tried your code in a blank Solution, using Visual Studio 2010, .NET Framework 4.0. Changing the following, I manage to avoid the full postback from the buttons:
I've added the AsyncPostBackTriger property for the Click event for each button and SelectedIndexChanged for the DropDownLists. Also I've configured the UpdatePanel properties ChildrenAsTriggers="false" and UpdateMode="Conditional". Following the same approach for every UpdatePanel will do the trick.
<asp:UpdatePanel ID="UpdatePanel4" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlTiming" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:DropDownList ID="ddlTiming" runat="server" Width="155px" Height="23px" AutoPostBack="True"
Class="valid" OnSelectedIndexChanged="ddlTiming_SelectedIndexChanged">
</asp:DropDownList>
<asp:Button ID="btnAdd" runat="server" Text="Add" />
<cc1:modalpopupextender id="btnAdd_ModalPopupExtender" runat="server" cancelcontrolid="btnCancleInsertTime"
dynamicservicepath="" enabled="True" popupcontrolid="Panel1" targetcontrolid="btnAdd">
</cc1:modalpopupextender>
</ContentTemplate>
</asp:UpdatePanel>
I've noticed that the button Schedule was not inside an Update Panel, so obviously it was causing full page postback.

Ajax ModelpopupExtender Cant work

I am using modelpopupextender in asp.net and this code is working window is popup sucessfuly but cancel button can't work; can anybody tell me why?
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp"
%>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Button ID="buttonOpen" runat="server" style="display:none" ></asp:Button>
<asp:Panel ID="Panel3" runat="server" BackColor="#99CCFF" Height="269px" Width="350px"
style="display:none">
<table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%"
cellpadding="0" cellspacing="0">
<tr style="background-color:#333399">
<td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger"
align="center">Time Details</td>
</tr>
<tr>
<td>
<asp:Label ID="Label19" runat="server" Text="Time From"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label20" runat="server" Text="Time To"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label21" runat="server" Text="Number of Slots"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Add" />
</td>
<td>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" OnCancelScript="btnCancel" PopupControlID="panel3" TargetControlID="buttonOpen" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
You need to set the CancelControlID property, not the OnCancelScript property (unless you want to execute a script after the cancel button is clicked). So for your scenario, do this:
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="btnCancel" PopupControlID="panel3" TargetControlID="buttonOpen" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>

Resources