以编程方式显示弹出是否在代码中弹出

时间:2013-09-26 01:09:55

标签: c# javascript asp.net popup

每一天的好日子,

你能帮我生成一个代码来生成弹出窗口,如返回确认吗?事情是它应该在一个方法内部而不是点击之后。

if (a == "1")
{
    //Page.ClientScript.RegisterStartupScript(this.GetType(), "messagebox", "<script>$(document).ready( function() { csscody.confirm('<br/><h1>  Confirmation</h1><br/>       We have currently existing Details for that Upload Proceed?<br/>',{onComplete: function(e){if(e){process();__doPostBack('ctl00$ContentPlaceHolder1$btnCommitSaving','');}}});return false;});</script>", false);
    //ClientScript.RegisterStartupScript(typeof(string), "messagebox", "<script language='javascript'>alert('Continue Uploading?.');</script>");
    // here a pop up message should appear if he press yes he will do the procedure if no the program will cancel the procedure  
 // the other one is just an alert with OK button not having Yes or no
}

我用//尝试了代码,但它没有工作,只是在调试模式下通过它。 我很抱歉,但我对javascripts的理解非常少。所以,请帮助我任何阅读材料,以供将来参考,这将是理想的,但带有解释的代码会更好,非常感谢你!

**修改

老实说起来我真的不知道为什么它不能在调试模式下工作它只是传入那个语句没有出现任何弹出框,我真的很抱歉,如果我不知道javascripts这就是为什么我要求帮助启发我,也是为了找到解决这个问题的方法。

1 个答案:

答案 0 :(得分:3)

ClientScript.RegisterStartupScript 

你应该只在你想要在页面首次加载时添加脚本而不是在回发后才能使用它,你可以使用javascript确认

Page.ClientScript.RegisterStartupScript(this.GetType(), 
"ButtonClickScript", "confirm('Please select date within the same month and year')", true);