Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day Everyone,

The following is part of my code

C#
//start code
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script>loadAdditionalInfoDialog(info1)</script>",false);

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp2", "<script>loadAdditionalInfoDialog(info2)</script>",false);
}
//end of code

The loadAdditionalInfoDialog() function will prompt a small window and let user to key in some info and then click on "OK" button to proceed to next step.

But, when I click on Button1, I can only see the secoond RegisterStartupScript, which is loadAdditionalInfoDialog(info2) works, it will prompt the small window, and I can key in some info and click on "OK" button to proceed to next step.

Because of this, I CAN NOT enter info for the first RegisterStartupScript, which is loadAdditionalInfoDialog(info1).

Would like to ask for solution which is, when I click on Button1, I can first enter info for loadAdditionalInfoDialog(info1) and then click on "OK" button, then continue enter info for loadAdditionalInfoDialog(info2).

Thousand of thanks.

Improve question here (code for loadAdditionalInfoDialog() in front page: )

JavaScript
// start javascript code
<script>
function loadAdditionalInfoDialog(info)
{
if (info == "")
alert("Please fill in quantity");
}
else
document.getElementById("<%=btn3InfoRefresh.ClientID %>").click();

</script>
// end of code



// start btn3InfoRefresh code
XML
protected void btn3InfoRefresh_Click(object sender, EventArgs e)
    {
        ucForm.ProductID = int.Parse(hid3InfoProductID.Value);
        ucForm.Values.Clear();
        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp"+i, "<script>showAdditionalInfoDialog();</script>", false);
    }

// end of code

The showAdditionalInfoDialog() is a function to pop out a window to let user key in information and click ok "OK" button to proceed to next step.

// start showAdditionalInfoDialog code
XML
function showAdditionalInfoDialog()
            {
                document.getElementById("<%=divAdditionalInfo.ClientID %>").style.visibility = "visible";
                document.getElementById("<%=divAdditionalInfo.ClientID %>").style.display = "table-cell";
            }


// end of code

I will do some improvement on my question because it make people confuse.
SQL
Actually the Button1_Click is just a button I create to do testing.
In fact, I only will call the loadAdditionalInfoDialog() when I get data in a Repeater :


C#
protected void btnRedeemAll_Click(object sender, EventArgs e)
    {
		foreach( RepeaterItem itm in repGiftResults.Items )
        {
			/*
			code to get all those parameter
			*/
			if (pr.AdditionalFieldsEnabled == true)
                    {
						ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script>loadAdditionalInfoDialog(1," + pr.ID + "," + giftId + ",'" + txtQty.ClientID + "'," + tokenId + ")</script>", false);
						
					}
		}
	}


Thus, I think it is hard for me to call the second time loadAdditonalInfoDialog() when I click on "OK" button, because I need to get many parameter in the repeater.
Posted
Updated 9-Jun-13 23:51pm
v5
Comments
Zoltán Zörgő 10-Jun-13 4:38am    
The problem is most likely in the loadAdditionalInfoDialog function. Please post it's code.
Jun Xian 10-Jun-13 5:31am    
Thanks for your reply.
Already post my code, you can have a look.
Let me know if my question have any mistake.
Thanks.

1 solution

Hi,

Why you want to call the two javascript function inside the Button1_Click Event. Instead Call only the first pop up inside the server side event.

Then call the second pop up from the client side of the first pop up, when okay button is clicked.

I hope you will get some idea.

Please reply me if my understanding of your problem was wrong.

Thanks
 
Share this answer
 
Comments
Jun Xian 10-Jun-13 5:52am    
Hi, Thanks for your reply. : )

I am understand your idea.

Actually my code is not simple as what I post there, I just try to simplify it. I try to explain my code a bit here :

Actually the Button1_Click is just a button I create to do testing.

In fact, I only will call the loadAdditionalInfoDialog() when I get data in a Repeater :

Please have a look on my question, I will edit on it at bottom part.

Please reply me if I make you confuse again.

Appreciate your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900