Solved

ModalPopupExtender execute code behind event HELP!

Posted on 2008-10-01
12
1,414 Views
Last Modified: 2013-12-17
Hi,

I am trying to fire out the modal popup to display and inform user that there are TBC values in the record.

If the user selects YES then it will carry on commiting the data etc... else stop everything.

I have implemented what I can, it executes the prompt when statement is true, which is what I want it to do, BUT when YES button is clicked, command is not doing what I want it to do. I have supplied code snippet (c#) to give you an idea what level I am at.

Note: the command I would like it to execute when YES clicked is:

        updateData();
        sendMail2();
        hardCopy();
        excelFile();
        DelLockSession();

Regards,

introlux

P.S
At the moment any time the button print is selected, it just does autopost back and nothing happens. It seems to get stuck on the screen with a refresh! So there is two problems. 1. it does not execute command and 2. it does not do anything when the button print is selected.
<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<br />

<br />

<div>

   <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none" Width="233px">

       There are TBC values, do you wish to still continue?<br />
 

   <br />

   <div align="center">

      <asp:Button ID="OkButton" runat="server" Text="Yes" />

      <asp:Button ID="CancelButton" runat="server" Text="No" />

   </div>

   </asp:Panel>

   <br />

   

   <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 

             TargetControlID="Button1"

             PopupControlID="Panel1"

             BackgroundCssClass="modalBackground"

             DropShadow="true"

             OkControlID="OkButton"

             OnOkScript="onOk()"

             CancelControlID="CancelButton" />

<asp:Button ID="Button1" runat="server" Text="Button" style="display:none" Visible="true" OnClick="Button1_Click" /></div>
 

----------------------------------------------------------------------
 

Code behind:
 

----------------------------------------------------------------------
 

    protected void btnPrint_Click(object sender, EventArgs e)

    {

        if (opProStatusDrop.SelectedValue == "Closed")

        {

            if (CheckIFNull() == true)

            {

                if (!chkFQC.Checked || !chkIR.Checked) //(chkFQC.Checked == false || chkIR.Checked == false)

                {

                    lblStatus.Text = "You have not confirmed check box";

                }

                else

                {

                    updateData();

                    sendMail();

                    hardCopy();

                    excelFile();

                    DelLockSession();

                    Response.Redirect("SessPrint.aspx");

                }

            }

        }

        if (opProStatusDrop.SelectedValue == "Open - complete")

        {

            if (CheckIFNull() == true)

            {

                if (!chkFQC.Checked || !chkIR.Checked) //(chkFQC.Checked == false || chkIR.Checked == false)

                {

                    lblStatus.Text = "You have not confirmed final quota counts or final response rate";

                }

                else

                {

                    updateData();

                    sendMail2();

                    hardCopy();

                    excelFile();

                    DelLockSession();

                    Response.Redirect("SessPrint.aspx");

                }

            }

        }

        if (opProStatusDrop.SelectedValue == "Open - field")

        {

            if (CheckIFTBC() == false)

            {

                ModalPopupExtender1.Show();

            }

            else

            {

                updateData();

                sendMail2();

                hardCopy();

                excelFile();

                DelLockSession();

                Response.Redirect("SessPrint.aspx");

            }

        }

    }
 

    protected void Button1_Click(object sender, EventArgs e)

    {

        updateData();

        sendMail2();

        hardCopy();

        excelFile();

        DelLockSession();

    }

Open in new window

0
Comment
Question by:introlux
  • 6
  • 5
12 Comments
 
LVL 7

Expert Comment

by:ajolly
ID: 22613671
in javascript function onOk()

write following:

__doPostBack(''<%=Button1.UniqueId%>'','');

or try to write the hard code the Unique ID of Button1.
0
 

Author Comment

by:introlux
ID: 22613877
Error:

Compiler Error Message: CS0117: 'System.Web.UI.WebControls.Button' does not contain a definition for 'UniqueId'

Source Error:

 

Line 15: AC_FL_RunContent = 0;
Line 16:         function btnOkClick() {
Line 17:             __doPostBack(''<%=Button1.UniqueId%>'','');
Line 18:
Line 19:
 
0
 
LVL 7

Expert Comment

by:ajolly
ID: 22613898
sorry for syntax, please use

Button1.UniqueID



or use the hard code unique id of Button1
0
 

Author Comment

by:introlux
ID: 22614000
It compiled but no output result!!
0
 
LVL 7

Expert Comment

by:ajolly
ID: 22614056
do you mean you see the popup and when click on YES button, Button1_Click is not being executed ?

please check by using breakpoint.
0
 

Author Comment

by:introlux
ID: 22614161
Do I see prompt = Yes
When clicking on YES = It does not do anything

Does not hit breakpoint! (in code behind)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22614515
Hi,

You do realise I actually provided you with an answer on how to do this in your other question on the same subject: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23765696.html ?

In your case it's just a matter of:

a)
    <script language="javascript" type="text/javascript">
        function btnOkClick(sender, e) {
            __doPostBack(sender,e);
        }
    </script>

b)
        if (!Page.IsPostBack) {
            OkButton.OnClientClick = string.Format("btnOkClick('{0}','{1}')", OkButton.UniqueID, "MODALPOSTBACK");
        }

c)

        if (Page.IsPostBack) {
            string PostBackMode = Page.Request.Params["__EVENTARGUMENT"];
            if (string.Compare(PostBackMode, "MODALPOSTBACK") == 0) {
                        updateData();
                        sendMail2();
                        hardCopy();
                        excelFile();
                        DelLockSession();
            }
        }

/Carl.
0
 

Author Comment

by:introlux
ID: 22614748
I have done both possible solutions and niether of them work!

The normal process is not working now. Also the popup box appears but when clicking yes nothing happens!
0
 
LVL 7

Expert Comment

by:ajolly
ID: 22614832
You have written code in

btnOkClick() {


but your OnOkScript is "onOk()"

should you write:

function onOk()
{
    __doPostBack('<%=Button1.UniqueID%>','');
}
0
 
LVL 7

Accepted Solution

by:
ajolly earned 500 total points
ID: 22614853
and use one single quote '<%=Button1.UniqueID%>' .

In your code you have used 2 single quotes
0
 

Author Closing Comment

by:introlux
ID: 31501896
I Cannot believe it was sommet minor like that!

Thanks
0
 

Author Comment

by:introlux
ID: 22623110
Just wanted to add, that this check works all good. BUT when the user clicks on another option:

opProStatusDrop.SelectedValue == ???? (to something else)

Due to the popup modal being executed, it will not allow the user re-select a differ option and allow them to bypass this.

Any idea??

Regards,

introlux
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now