?
Solved

open confirmation in middle of button click event

Posted on 2009-02-18
9
Medium Priority
?
242 Views
Last Modified: 2013-12-17
I see some people asked this question before. But I can not fully understand the solution or it was not solved at all.

Basically I have a button on C# web application page. Once user clicks the button it call some other function/process to get result. let's say the result is a string saved in a textbox on the page. Based on the string value 'yes' or 'No' to open confirmation or not, then catch the user's response from the confirmation to do rest stuff.

sample code:
==========================================
        protected void OverRide_Click(object sender, EventArgs e)
        {
            myResult.Text = "";
            myResult.Text = myFirstCheck(Customer.Text);
            if (Confirmation())
            {
                OverRideCustomer(Customer.Text, myResult.Text) ;
            }
            else
           {
               SendMessageToCust(Customer.Text)
           }
        }

==========================================================
Thnaks for help
0
Comment
Question by:lanac222
  • 4
  • 3
  • 2
9 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 23675678
if you can use ajax you can use the modalpopupextender.

just popup a panel with the result in it and a yes and no button. then you can handle the button click event for their choice


 protected void OverRide_Click(object sender, EventArgs e)
        {
            myResult.Text = "";
            myResult.Text = myFirstCheck(Customer.Text);
            modalpopupextender.Show();
        }
 
protected void ConfirmationYes_Click(object sender, EventArgs e)
        {
            OverRideCustomer(Customer.Text, myResult.Text) ;
        }
 
protected void ConfirmationNo_Click(object sender, EventArgs e)
        {
            SendMessageToCust(Customer.Text)
        }

Open in new window

0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 23675681
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676158
You could do that with javascript.

if (document.getElementById("txtResponse").Value = "Yes")
{
   var answer = confirm("Are you sure?");
    if (answer) {
      return true;
    } else {
      return value;
}
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23676161
Oops, that should be return false; in that else statement.
0
 

Author Comment

by:lanac222
ID: 23682011
I fixed it by myself.
0
 
LVL 15

Expert Comment

by:aibusinesssolutions
ID: 23682718
What did you do to fix it?  
0
 

Author Comment

by:lanac222
ID: 23683808
OK, I still need help for this.

In cs code I set a value to a text field, say "OVERRIDE" and the script function for onload check the text field value. if it is OVERRIDE then call confirm. if return true then set another text field "YES", otherwise set "NO"
Following in the event to run process based on the 'yes' or 'no'.

My problem now is before exist the event the second text field is not set value. that mean the js function doesn't immediately execute.
How to make the js run immediately?
I was trying AJAX. But it doesn't work, it alway pop confirmation before do anything in the event.
Then I remove AJAX from the page.

=========================== cs code ===============
        protected void OverRide_Click(object sender, EventArgs e)
        {
            myResp.Text = "";
            ErrMessage.Text = "";
            // first call post with no override
            myRespL.Text = wInv.PostTankTemplate(strConnOC, txtInvDate.Text.Trim(),
                ddlBuilding.SelectedValue.Trim(), Session["login"].ToString().Trim(), "NO");
           //check return message for repost
            if (myResp.Text.Trim().Substring(myURL.Text.Trim().LastIndexOf("o"), 9) == "override?")
            {
                myParam.Text = "OVERRIDE";
                 ErrMessage.Text = wInv.PostTank(strConnOC, txtInvDate.Text.Trim(),
                    ddlBuilding.SelectedValue.Trim(), Session["login"].ToString().Trim(), myResp.Text.Trim());
            }
        }
======================================

========================= js =========================
<script>
      function CheckStatus()
      {
        if (document.MainForm.myParam.value == "OVERRIDE")
         {
             if (confirm(document.MainForm.myResp.value))
                   {
               document.MainForm.myParam.value="";
               document.MainForm.myResp.value="YES";
               }
               else
               {
               document.MainForm.myParam.value="";
               document.MainForm.myResp.value="NO";
               }
               
         }
    }  
    </script>
</head>
<body onload="CheckStatus()" onunload="CloseSubForms()">
    <form id="MainForm" method="post" runat="server">
0
 

Author Comment

by:lanac222
ID: 23686593
I still need help.
0
 

Accepted Solution

by:
lanac222 earned 0 total points
ID: 23692509
Yes, I'd like to open this question
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 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