在c#中多次运行RegisterStartupScript [英] Run RegisterStartupScript multiple times in c#

查看:69
本文介绍了在c#中多次运行RegisterStartupScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天每个人,



以下是我的代码的一部分



Good day Everyone,

The following is part of my code

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



loadAdditionalInfoDialog()函数将提示一个小窗口,让用户输入一些信息,然后点击确定按钮继续下一步。



但是,当我点击Button1时,我只能看到secoond RegisterStartupScript,这是loadAdditionalInfoDialog(info2)的工作原理,它会提示小窗口,我可以输入一些信息并单击确定按钮继续下一步。



因此,我无法输入第一个RegisterStartupScript的信息,即loadAdditionalInfoDialog(info1)。



想要求解决方案,当我点击Button1时,我可以先输入loadAdditionalInfoDialog(info1)的信息,然后点击确定按钮,然后继续输入loadAdditionalInfoDialog的信息( info2)。



万分感谢。



在这里改善提问de for frontAdditionalInfoDialog()在首页:)




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

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




// start btn3InfoRefresh code

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);
    }



//代码结束



showAdditionalInfoDialog()是一个弹出的函数在一个窗口中让用户输入信息,然后单击确定确定按钮继续下一步。



//启动showAdditionalInfoDialog代码


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

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.

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 :







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);
						
					}
		}
	}





因此,我觉得很难当我点击确定按钮时,我第二次调用loadAdditonalInfoDialog(),因为我需要在转发器中获取许多参数。



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.

推荐答案





为什么要调用Button1_Click事件中的两个javascript函数。而是仅调用服务器端事件内的第一个弹出窗口。



然后在点击确定按钮时,从第一个弹出窗口的客户端调用第二个弹出窗口。



我希望你会有所了解。



如果我对你的问题的了解是,请回复我错误。



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


这篇关于在c#中多次运行RegisterStartupScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆