Semil Sebastian
Semil Sebastian

Reputation: 519

ModalPopupExtender hides when dropdown post back works

I have a model pop up extender, within this pop up i have a dropdown list with AutopostBack="True". Now when I select one dropdown value the ModalPopupExtender hides. Let me know the reason??? Someone preferred to put update panel but still the problem exists

My pop up controls is,

  <cc1:ToolkitScriptManager runat="server" ID="ToolkitScriptManager1" EnableScriptGlobalization="true"></cc1:ToolkitScriptManager>            
  <asp:HiddenField ID="HiddenField1" runat="server" />
  <cc1:ModalPopupExtender ID="ModalPopupExtender3" runat="server" 
  BehaviorID="modalPopupExtender3" 
  TargetControlID="HiddenField1"
  OkControlID="cancel1" 
  BackgroundCssClass="modalPopup" >
  </cc1:ModalPopupExtender> 

 <!-- Update section-->

  <div id="updatdediv1" visible="false" >
  <div class="portlet box blue" id="Div3">
  <div class="portlet-title">
  <div class="caption"><i class="icon-reorder"></i> Add Salary Component </div>
   <div class="tools">
<asp:imagebutton ID="Imagebutton2" runat="server"  class="close" ImageUrl="~/jimage/clossse.PNG" />
</div>
</div>
<div class="portlet-bodypop">
<div class="controls">
<label class="control-label">Pay Grade:</label>
<asp:DropDownList ID="ddpaygrade" runat="server" AutoPostBack="true" class="m-wrap large" AppendDataBoundItems="false" ></asp:DropDownList>
 </div>
 <div class="controls">
 <label class="control-label">DA %:</label>
 <asp:TextBox ID="txtda" runat="server" class="m-wrap large" ReadOnly="true"></asp:TextBox>
 </div>
 <div class="controls">
                                <label class="control-label">Basic:</label>
                             <asp:TextBox ID="txtbasic" runat="server" class="m-wrap large"></asp:TextBox>
    </div>
    <div class="controls">
    <label class="control-label">Calculated DA:</label>
    <asp:TextBox ID="txtcalculatedDA" class="m-wrap large" runat="server" ></asp:TextBox>
    </div>
    <div class="form-actions1">
    <button id="Button2"onclick="myFunction()"" style="display:none" >Save</button>
   <asp:Button ID="btnedit2" runat="server" Text="Submit"  CssClass="btn blue"  ValidationGroup="grp1"   />     
                            &nbsp;&nbsp;
  <asp:Button ID="btncancel3" runat="server" Text="Cancel" CssClass="btn"/>
                            <asp:Label ID="label1" runat="server" Text="" Visible="false"></asp:Label>
 </div>
 </div>
 </div>
 </div>
  <!-- temp panel-->                                        
  <asp:Panel ID="kj" runat="server"  >
  <table  >
  <tr><td class="style9">
  <table >
  <tr> <td class="style8"> &nbsp;</td>     </tr>
  <tr >
  <td align="left" class="style12">
   <asp:Button ID="cancel1" runat="server"  Text="Cancel" Style=" display:none" 

   </td>
   </tr>
   </table>
   </td></tr></table> 
   </asp:Panel>       

Upvotes: 0

Views: 1198

Answers (1)

Josh Darnell
Josh Darnell

Reputation: 11433

If you need the modal popup extender to "survive" the postback, then you will have to manage that yourself. Handle the dropdown's SelectedIndexChanged event and show the popup there:

protected void ddpaygrade_SelectedIndexChanged(object sender, EventArgs e)
{
    ModalPopupExtender3.Show();
}

Don't forget to wire-up the event in your markup:

<asp:DropDownList ID="ddpaygrade" runat="server" AutoPostBack="true" 
    class="m-wrap large" AppendDataBoundItems="false" 
    OnSelectedIndexChanged="ddpaygrade_SelectedIndexChanged" >    
</asp:DropDownList>

Upvotes: 3

Related Questions