protected void btnOkay_Click(object sender, EventArgs e)
        {
            Boolean blBill = checkBill();

            if (blBill == true)
            {
                SqlCommand cmdRegistrationID = new SqlCommand("SELECT RegistrationID FROM Registration WHERE RegistrationID = @id", conOOC);
                cmdRegistrationID.Parameters.AddWithValue("@id", txtRegistrationID.Text);

                conOOC.Open();
                SqlDataReader dtrRegistrationID = cmdRegistrationID.ExecuteReader();

                if (dtrRegistrationID.HasRows)
                {
                    while (dtrRegistrationID.Read())
                    {
                        Server.Transfer("Make Payment.aspx", true);
                    }
                }
                else
                {
                    Response.Write("<script>alert('Record Not Found.! Please Enter Correctly.');</script>");
                    txtRegistrationID.Focus();
                    txtRegistrationID.Attributes.Add("onfocus", "this.select();");
                }

                conOOC.Close();
            }
            else
            {
                Response.Write("<script>alert('You've Already Made The Payment. Thank You.');</script>");
            }

when the blBill = true and if the dtrRegistrationID.HasRows = false it will go to "else" statement and show the messagebox popup. It's success to display but if the blBill = false, it doesn't show any messagebox popup. Anyone know why? @@

Recommended Answers

All 9 Replies

The issue is not with the logic. I suspect if you simply do a response.write("Hello World!") it will work.

Take a look at this asp.net posting that deals with attempting to execute an alert method.
http://forums.asp.net/t/1051178.aspx/1

im not facing the problem of new line, but i am facing a problem which
Response.Write("<script>alert('You've Already Made The Payment. Thank You.');</script>");
cannot be displayed.?

Oh, I see what the problem is. You have an apostrophe in your text. Try this instead.

Response.Write("<script>alert('You have Already Made The Payment. Thank You.');</script>");

i don't seem any differences? :o but i try it later on.

Your code:

You've Already Made The Payment. Thank You.

Change You've to You have. The apostrophe in You've is causing the problem.

Oh ya, i solved the problem because the single quotation. Thank for solve the problem. but i am facing the same problem but different event(Image Button Click)

        protected void imgbtPaypal_Click(object sender, ImageClickEventArgs e)
        {
            double dblTotalAmount = double.Parse(lblTotalAmount.Text) + penaltyAmt;
            string email = "OlympiaOpenCollege@gmail.com";
            string programmeName = lblProgramme.Text;
            string courseName = lblCourse.Text;
            string semester = lblSemester.Text;
            string return_URL = "http://localhost:3120/Enter%20Reference.aspx";

            generatePaymentID();
            generateBillID();
            setPayment();
            setBill();

            Response.Write("<script>alert('Please Write Down The Transaction Number After Made Payment.');</script>");

            //Build a URL String for the redirect
            string paypalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + email + "&item_name=Olympia Open College Tuition Fees +" + programmeName + "+- " + courseName + "+" + semester + "&amount=" + dblTotalAmount + "&return=" + return_URL;
            Response.Redirect(paypalURL);

any ideas why the response.write not function at all while i click the image?
i've double check for the statement, it should be alright.

I noticed during some testing on my own that the response.write doesnt seem to execute on the screen when there is a response.redirect executing after the response.write.

I found this explanation online:
When Response.Redirect is used the expectation is to send only the 302 header to the client. Hence by default, it flushes the response & aborts the current thread, so the subsequent action will not be performed: Source

Alright. i've solved the problem already by using two events.
one is Server Click Event what i wrote above, another one is

<asp:imageButton ID="imgbtPaypal" runat="server" 
                    ImageUrl="~/Images/Paypal.gif" onclick="imgbtPaypal_Click" OnClientClick="alert('Please Write Down The Transaction Number After Made Payment.');" />

so it's fine right now. Thank You.

And i also tried another way of doing it. Which is combine them together and call them as .Write.

Response.Write("<script>alert('hihi');window.open('" + paypalURL + "', '_self');</script>");

very good solution. glad to hear you resolved it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.