javascript确认窗口获取bool值
我有一个名为 addtitle.aspx 的页面 - 在这里我将上传用户提交的文档...
毕竟我会将此页面重定向到 versions.aspx...
现在我的问题是...
我需要确认该用户喜欢在转到 Version.aspx 之前预览文档...
这里我将显示一个确认窗口,但我无法预测用户选择的是或否的值..
供参考: ///////////////////////////////
bool sStatus = ShowPopupMessage("You want to preview the document?");
if(sStatus)
{
//Preview event
}
else
{
response.redirect("");
}
private bool ShowPopupMessage(string Message)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("return confirm('");
sb.Append(Message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "return confirm", sb.ToString(),true);
}
是否可以预测用户是否选择“是”?
i have a Page called addtitle.aspx - here i will upload a document which is submitted by a user...
after all i will redirect this page into versions.aspx....
Now my question is...
i need to confirm that user like to preview the document before going to Version.aspx...
Here i ll show a confirm window but i cant predict the values chosen by user either Yes or no..
For ref:
///////////////////////////////
bool sStatus = ShowPopupMessage("You want to preview the document?");
if(sStatus)
{
//Preview event
}
else
{
response.redirect("");
}
private bool ShowPopupMessage(string Message)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script type = 'text/javascript'>");
sb.Append("window.onload=function(){");
sb.Append("return confirm('");
sb.Append(Message);
sb.Append("')};");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(), "return confirm", sb.ToString(),true);
}
Is it possible to predict that if the user has chosen "Yes"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,在用户单击“确定”或“取消”后,您需要对服务器端代码进行 AJAX 调用。
这意味着您无法从 C# 函数返回状态。
No, you will need to make an AJAX call to your server-side code after the user clicked OK or Cancel.
This means you cannot return the status from your C# function.