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

Programatically Shows a Pop Yes No Pop up inside a code

本文关键字:是否 代码 编程 方式 显示      更新时间:2023-09-26

美好的一天 每个人,

你能帮我生成一个代码来生成弹出窗口,如返回确认吗? 问题是它应该在方法中而不是在单击后。

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
}

我尝试了使用//的代码,但它不起作用,它只是在调试模式下经过它。我很抱歉,但我对JavaScript的了解非常少。因此,请帮助我为将来参考的任何阅读材料都是理想的,但带有解释的代码会更好 非常感谢!

**编辑

老实说,我真的不知道为什么它在调试模式下不起作用,它只是传入该语句而没有任何弹出框出现,如果我不知道 JavaScript,我真的很抱歉这就是为什么我寻求帮助来启发我,也想办法解决这个问题。

ClientScript.RegisterStartupScript 

仅当您想在页面首次加载时添加脚本而不是在回发后添加脚本时,才应该执行此操作,您可以使用 JavaScript 确认

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