Solved

ModalPopupExtender execute code behind event HELP!

Posted on 2008-10-01
12
1,432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 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