You must Sign In to post a response.
  • Category: .NET

    Modal popup extender

    how to display runtime error inside modalpoup extender on button click event.
  • #761826
    Hi Pratheepa,

    Assume that this is your modal design part.


    <asp:Button ID="btnShowPopup" Text="Show Popup" runat="server" Style="display: none" />
    <cc1:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btnShowPopup"
    PopupControlID="pnlPopup" BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
    <asp:Panel ID="pnlPopup" runat="server" BackColor="White" Height="100px"
    Width="400px" Style="display: none">
    <table width="100%" style="border: Solid 2px #D46900; width: 100%; height: 100%"
    cellpadding="0" cellspacing="0">
    <tr style="background-image: url(~/Images/header.gif)">
    <td style="height: 10%; color: White; font-weight: bold; padding: 3px; font-size: larger;
    font-family: Calibri" align="left">
    Confirm Box
    </td>
    <td style="color: White; font-weight: bold; padding: 3px; font-size: larger" align="right">
    <a href="javascript:void(0)" onclick="closepopup()">
    <img src="~/Images/Close.gif" style="border: 0px" align="right" /></a>
    </td>
    </tr>
    <tr>
    <td colspan="2" align="left" style="padding: 5px; font-family: Calibri; font-size: 12px;">
    <asp:Label ID="lblErrorText" runat="server" ></asp:Label>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    </td>
    </tr>
    <tr>
    <td>
    </td>
    <td align="right" style="padding-right: 15px">
    <asp:ImageButton ID="btnYes" OnClick="btnYes_Click" runat="server"
    ImageUrl="~/Images/btnyes.jpg" />
    <a href="javascript:void(0)" onclick="closepopup()">
    <img src="~/Images/btnNo.jpg" style="border: 0px" align="right" /></a>
    </td>
    </tr>
    </table>
    </asp:Panel>


    In the above design "lblErrorText" is the label control to display the content whenever you want to show the Error message then you can use that label and assign your error details to that label.

    Hope you understood..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #761827
    Hi naveensanagasetti,

    i want to show runtime error message.
    eg: messagebox("Nothing to saved");

    when error msg display poup hide. how can i solved

    Delete Attachment

  • #761828
    Hi Pratheepa,

    messagebox is windows application feature, if you are Windows application developer then you can use messagebox, if you need this in web application then @ runtime open modal dialog and assign label value at runtime.

    EX:

    try
    {
    }
    Catch(Exception ex)
    {
    modal.Show();
    lblError.Text=ex.Message;
    }


    like that you can handle at runtime, please try it if you face any issue then please let me know..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #761831
    Hi
    You can try this code

    Client side


    <asp:UpdateProgress ID="UpPrgress" runat="server" AssociatedUpdatePanelID="upPnls">
    <ProgressTemplate>
    <asp:Image ID="Image1" ImageUrl="waiting.gif" AlternateText="Processing" runat="server" />
    </ProgressTemplate>
    </asp:UpdateProgress>
    <ajaxToolkit:ModalPopupExtender ID="modalPopup" runat="server" TargetControlID="UpPrgress"
    PopupControlID="UpPrgress" BackgroundCssClass="modalPopup" />
    <asp:UpdatePanel ID="uppnlnew" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:Panel ID="pnl" runat="server">
    <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
    </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>


    Server side

    modalPopup.show();
    lblError.Text = "Error Message Here";

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761947
    Hello Pratheepa,

    You can use the below code :

    HTML Mark up :

    <html>
    <head><title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
    Name : <asp:TextBox ID="TextBoxName" runat="server" Enabled="False"></asp:TextBox><br />
    Class : <asp:TextBox ID="TextBoxClass" runat="server" Enabled="False"></asp:TextBox><br /><br />

    <asp:Button ID="ButtonShowDialog" runat="server" Text="Show Dialog" ToolTip="Show student details"/>
    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="ButtonShowDialog" BackgroundCssClass="modalBackground" Enabled="true" PopupControlID="Panel1" Drag="false"></cc1:ModalPopupExtender>
    <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
    <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Select</asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
    <asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" />
    </Columns>
    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
    <SortedAscendingCellStyle BackColor="#FDF5AC" />
    <SortedAscendingHeaderStyle BackColor="#4D0000" />
    <SortedDescendingCellStyle BackColor="#FCF6C0" />
    <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [StudentDetails]"></asp:SqlDataSource>
    <br />
    <asp:Button ID="ButtonClose" runat="server" Text="Close" OnClick="ButtonClose_Click"/>
    <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
    </asp:Panel>
    </div>
    </form>
    </body>
    </html>


    Code behind :

    private void closepopup()
    {
    ModalPopupExtender1.Hide();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
    TextBoxName.Text = null;
    TextBoxClass.Text = null;
    }


    protected void LinkButton1_Click(object sender, EventArgs e)
    {
    try
    {
    GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
    int index = gvRow.RowIndex;

    TextBoxName.Text = GridView1.Rows[index].Cells[1].Text;
    TextBoxClass.Text = GridView1.Rows[index].Cells[2].Text;
    closepopup();
    }
    catch(Exception ex)
    {
    lblError.Text = ex.Message;
    }
    }

    protected void ButtonClose_Click(object sender, EventArgs e)
    {
    closepopup();
    }


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"


Sign In to post your comments