[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ModalPopupExtender execute code behind event HELP!

Posted on 2008-10-01
12
Medium Priority
?
1,442 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

649 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