locked
requiredfieldvalidator in modalpop prevent modalpopup from showing RRS feed

  • Question

  • User702049738 posted

    hello experts;

    I have the following requiredfieldvalidator code below. when i add it to the panel, my modalpopup doesn't show up anymore. please help. i am using visual studio 2008 framework 3.5


    <asp:RequiredFieldValidator ID = "reqddlstarthh"
    runat = "server"
    ControlToValidate = "ddlstarthh"
    InitialValue= ""
    Display = "Dynamic"
    ErrorMessage = "Please pick a start hh">
    </asp:RequiredFieldValidator>

    <asp:Button ID="HiddenTargetControlForModalPopup" runat="server" Style="display: none" />
    <ccl:ModalPopupExtender ID="ModalPopupExtender_btnnewdayshift" runat="server" PopupControlID="PNL"
    CancelControlID="imgbtnmodalpopupdayclose" BackgroundCssClass="modalpopupbackground"
    TargetControlID="HiddenTargetControlForModalPopup">
    </ccl:ModalPopupExtender>
    <asp:Panel ID="PNL" runat="server" CssClass="modalPopup" Height="200px" Width="300px"
    Style="display: none">

    <asp:DropDownList ID="ddlstarthh" runat="server">
    <asp:ListItem Text = "" Value=""></asp:ListItem>
    <asp:ListItem Value="01">1</asp:ListItem>
    <asp:ListItem Value="02">2</asp:ListItem>
    <asp:ListItem Value="03">3</asp:ListItem>
    <asp:ListItem Value="04">4</asp:ListItem>
    <asp:ListItem Value="05">5</asp:ListItem>
    <asp:ListItem Value="06">6</asp:ListItem>
    <asp:ListItem Value="07">7</asp:ListItem>
    <asp:ListItem Value="08">8</asp:ListItem>
    <asp:ListItem Value="09">9</asp:ListItem>
    <asp:ListItem Value="10">10</asp:ListItem>
    <asp:ListItem Value="11">11</asp:ListItem>
    <asp:ListItem Value="12">12</asp:ListItem>
    </asp:DropDownList>

    </panel>

    Saturday, August 20, 2016 5:53 PM

Answers

  • User283571144 posted

    Hi olybobo,

    I have the following requiredfieldvalidator code below. when i add it to the panel, my modalpopup doesn't show up anymore. please help. i am using visual studio 2008 framework 3.5

    According to your codes and description, I suggest you could change your codes as below:

    1. Delete "Style="display: none"".

    Reason: I find this button is used to show the model pop up, so you couldn't hide it.

    <asp:Button ID="HiddenTargetControlForModalPopup" runat="server" Style="display: none" />

    2.Add Close button inside panel

    Reason:I find you had defined "CancelControlID" in "ccl:ModalPopupExtender" control, but you didn't add it inside panel.

     <asp:Panel ID="PNL" runat="server" CssClass="modalPopup" Height="200px" Width="300px" Style="display: none">
                      <asp:Button ID="imgbtnmodalpopupdayclose" runat="server" Text="Close" />
         

    More details, you could refer to follow codes:

         <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:RequiredFieldValidator ID="reqddlstarthh"
                    runat="server"
                    ControlToValidate="ddlstarthh"
                    InitialValue=""
                    Display="Dynamic"
                    ErrorMessage="Please pick a start hh">
                </asp:RequiredFieldValidator>
    
          
                <asp:Button ID="HiddenTargetControlForModalPopup" runat="server"  Text="Show Modal Popup"  />
                <asp:Button ID="Button1" runat="server" Text="Button" />
                <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender_btnnewdayshift" runat="server"
                     PopupControlID="PNL"
                    CancelControlID="imgbtnmodalpopupdayclose" BackgroundCssClass="modalpopupbackground"
                    TargetControlID="HiddenTargetControlForModalPopup">
                </ajaxToolkit:ModalPopupExtender>
                  
                
                <asp:Panel ID="PNL" runat="server" CssClass="modalPopup" Height="200px" Width="300px" Style="display: none">
                      <asp:Button ID="imgbtnmodalpopupdayclose" runat="server" Text="Close" />
                    <asp:DropDownList ID="ddlstarthh" runat="server">
    
                        <asp:ListItem Text="" Value=""></asp:ListItem>
                        <asp:ListItem Value="01">1</asp:ListItem>
                        <asp:ListItem Value="02">2</asp:ListItem>
                        <asp:ListItem Value="03">3</asp:ListItem>
                        <asp:ListItem Value="04">4</asp:ListItem>
                        <asp:ListItem Value="05">5</asp:ListItem>
                        <asp:ListItem Value="06">6</asp:ListItem>
                        <asp:ListItem Value="07">7</asp:ListItem>
                        <asp:ListItem Value="08">8</asp:ListItem>
                        <asp:ListItem Value="09">9</asp:ListItem>
                        <asp:ListItem Value="10">10</asp:ListItem>
                        <asp:ListItem Value="11">11</asp:ListItem>
                        <asp:ListItem Value="12">12</asp:ListItem>
                    </asp:DropDownList>
    
    
                </asp:Panel>

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 22, 2016 1:35 PM

All replies

  • User-1642217485 posted

    Hi olybobo,

    According to your description , I note that you set panel and button tag  display property is none, you should set it to block. 

    Sample Code :

    Body :

    <body>
        <form id="form1" runat="server">
        <div>
              <asp:Panel ID="PNL" runat="server" CssClass="modalPopup" Height="200px" Width="300px" Style="display:block">
    
              <asp:RequiredFieldValidator ID = "reqddlstarthh" runat = "server" ControlToValidate = "ddlstarthh" InitialValue= "" 
              Display = "Dynamic"  ErrorMessage = "Please pick a start hh">
              </asp:RequiredFieldValidator>
    
              <asp:Button ID="HiddenTargetControlForModalPopup" runat="server" Style="display:block" />
    
                    <asp:DropDownList ID="ddlstarthh" runat="server">
                     <asp:ListItem Text = "" Value=""></asp:ListItem> 
                     <asp:ListItem Value="01">1</asp:ListItem>
                     <asp:ListItem Value="02">2</asp:ListItem>
                     <asp:ListItem Value="03">3</asp:ListItem>
                     <asp:ListItem Value="04">4</asp:ListItem>
                     <asp:ListItem Value="05">5</asp:ListItem>
                     <asp:ListItem Value="06">6</asp:ListItem>
                     <asp:ListItem Value="07">7</asp:ListItem>
                     <asp:ListItem Value="08">8</asp:ListItem>
                     <asp:ListItem Value="09">9</asp:ListItem>
                     <asp:ListItem Value="10">10</asp:ListItem>
                     <asp:ListItem Value="11">11</asp:ListItem>
                     <asp:ListItem Value="12">12</asp:ListItem>
                     </asp:DropDownList>
    
              </asp:Panel>
        </div>
        </form>
    </body>

    Screenshot:

    I hope this solution can solve your problem !

    Best Regards,

    Eric Du

    Sunday, August 21, 2016 7:26 AM
  • User283571144 posted

    Hi olybobo,

    I have the following requiredfieldvalidator code below. when i add it to the panel, my modalpopup doesn't show up anymore. please help. i am using visual studio 2008 framework 3.5

    According to your codes and description, I suggest you could change your codes as below:

    1. Delete "Style="display: none"".

    Reason: I find this button is used to show the model pop up, so you couldn't hide it.

    <asp:Button ID="HiddenTargetControlForModalPopup" runat="server" Style="display: none" />

    2.Add Close button inside panel

    Reason:I find you had defined "CancelControlID" in "ccl:ModalPopupExtender" control, but you didn't add it inside panel.

     <asp:Panel ID="PNL" runat="server" CssClass="modalPopup" Height="200px" Width="300px" Style="display: none">
                      <asp:Button ID="imgbtnmodalpopupdayclose" runat="server" Text="Close" />
         

    More details, you could refer to follow codes:

         <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:RequiredFieldValidator ID="reqddlstarthh"
                    runat="server"
                    ControlToValidate="ddlstarthh"
                    InitialValue=""
                    Display="Dynamic"
                    ErrorMessage="Please pick a start hh">
                </asp:RequiredFieldValidator>
    
          
                <asp:Button ID="HiddenTargetControlForModalPopup" runat="server"  Text="Show Modal Popup"  />
                <asp:Button ID="Button1" runat="server" Text="Button" />
                <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender_btnnewdayshift" runat="server"
                     PopupControlID="PNL"
                    CancelControlID="imgbtnmodalpopupdayclose" BackgroundCssClass="modalpopupbackground"
                    TargetControlID="HiddenTargetControlForModalPopup">
                </ajaxToolkit:ModalPopupExtender>
                  
                
                <asp:Panel ID="PNL" runat="server" CssClass="modalPopup" Height="200px" Width="300px" Style="display: none">
                      <asp:Button ID="imgbtnmodalpopupdayclose" runat="server" Text="Close" />
                    <asp:DropDownList ID="ddlstarthh" runat="server">
    
                        <asp:ListItem Text="" Value=""></asp:ListItem>
                        <asp:ListItem Value="01">1</asp:ListItem>
                        <asp:ListItem Value="02">2</asp:ListItem>
                        <asp:ListItem Value="03">3</asp:ListItem>
                        <asp:ListItem Value="04">4</asp:ListItem>
                        <asp:ListItem Value="05">5</asp:ListItem>
                        <asp:ListItem Value="06">6</asp:ListItem>
                        <asp:ListItem Value="07">7</asp:ListItem>
                        <asp:ListItem Value="08">8</asp:ListItem>
                        <asp:ListItem Value="09">9</asp:ListItem>
                        <asp:ListItem Value="10">10</asp:ListItem>
                        <asp:ListItem Value="11">11</asp:ListItem>
                        <asp:ListItem Value="12">12</asp:ListItem>
                    </asp:DropDownList>
    
    
                </asp:Panel>

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 22, 2016 1:35 PM