如何实现用C#实现javascript中的confirm()效果?

qyly 2003-08-23 09:50:53
也就是能有javascript中的confirm()的显示效果,但是我在C#代码端得不到返回值。
我想通过更改控件的值来得到confirm()的返回值但没实现!
...全文
121 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
wacle 2003-08-25
  • 打赏
  • 举报
回复
in page_load.
button1.Attrubutes["onclick"]="javascript:return confirm('hello,MM!')";
qyly 2003-08-25
  • 打赏
  • 举报
回复
fei30wang(草天海) :你说得对!!!
fei30wang 2003-08-25
  • 打赏
  • 举报
回复
不能解决!服务器不应等待!
neodotnet 2003-08-23
  • 打赏
  • 举报
回复
Button1.Attributes["onClick"] = "javascript:return confirm('OK or Cancel ?');";
lemong 2003-08-23
  • 打赏
  • 举报
回复
当年也是这个问题好难办,现在看到这么简洁的坚决方法,虚心学习!
panyee 2003-08-23
  • 打赏
  • 举报
回复
sumanden(心头慌,打中张) 真幽默哟

<asp:button ...>
给它服务端加上btn.Attributes.Add("onclick", "return confirm();");
生成html后它就等于

<input type=submit onclick="return confirm()

siugwan 2003-08-23
  • 打赏
  • 举报
回复
学习中!
Meyer 2003-08-23
  • 打赏
  • 举报
回复
版主
常规做法是
buttonname.Attributes["onclick"] = "return confirm('really?')";

是不是 MessageBoxNET 用多了 :)
「已注销」 2003-08-23
  • 打赏
  • 举报
回复
再晕,“其它”更正为“其他”:(
「已注销」 2003-08-23
  • 打赏
  • 举报
回复
晕,把第一种方法写错了,就不改了,参见其它朋友的:(
「已注销」 2003-08-23
  • 打赏
  • 举报
回复
一、常规做法:
Button1.Attribute.Add("<script language='javascript'>return confirm('你真的要这么做吗?')</script>");
上述代码放在Page_Load事件中
当点击Button1时,将弹出窗口显示“你真的要这么做吗?”,如果你点击“是”,则将执行Button_Click的服务器端事件,如果点击“否”,则不执行Button_Click事件。
二、使用三方控件:
使用MessageBoxNET控件,此控件用于Asp.Net对话框,功能与windows程序下的对话框相当,可定义窗体Caption和提示内容,以及定义显示什么按纽,哪些按纽点击后将返回服务器端,可在服务器端根据返回值进行相应处理。
演示地址:http://www.sorke.com/demo/messageboxnetdemo/advanced.aspx
下载地址:http://www.sorke.com/downcontrol.aspx 控件类型:其它控件

prczf 2003-08-23
  • 打赏
  • 举报
回复
上面的onclike应为onclick.
比如:
Button1.Attributes.Add("onclick"," return confirm('are you sure?')");
caoit 2003-08-23
  • 打赏
  • 举报
回复
Response.Write("<script language=javascript>confirm('Helllo")</script>");
prczf 2003-08-23
  • 打赏
  • 举报
回复
<control name>.Attributes.Add("onclike"," return confirm('are you sure?')");
Silverlight is a framework for building rich, browser-hosted applications that run on a variety of operating systems. Silverlight works its magic through a browser plug-in. When you surf to a web page that includes some Silverlight content, this browser plug-in runs, executes the code, and renders that content in a specifically designated region of the page. The important part is that the Silverlight plug-in provides a far richer environment than the traditional blend of HTML and JavaScript that powers ordinary web pages. Used carefully and artfully, you can create Silverlight pages that have interactive graphics, use vector animations, and play video and sound files. If this all sounds eerily familiar, it’s because the same trick has been tried before. Several other technologies use a plug-in to stretch the bounds of the browser, including Java, ActiveX, Shockwave, and (most successfully) Adobe Flash. Although all these alternatives are still in use, none of them has become the single, dominant platform for rich web development. Many of them suffer from a number of problems, including installation headaches, poor development tools, and insufficient compatibility with the full range of browsers and operating systems. The only technology that’s been able to avoid these pitfalls is Flash, which boasts excellent cross-platform support and widespread adoption. However, Flash has only recently evolved from a spunky multimedia player into a set of dynamic programming tools. It still offers far less than a modern programming environment like .NET. That’s where Silverlight fits into the picture. Silverlight aims to combine the raw power and cross-platform support of Flash with a first-class programming platform that incorporates the fundamental concepts of .NET. At the moment, Flash has the edge over Silverlight because of its widespread adoption and its maturity. However, Silverlight boasts a few architectural features that Flash can’t match—most importantly, the fact that it’s based on a scaled-down version of .NET’s common language runtime (CLR) and allows developers to write client-side code using pure C#. Understanding Silverlight Silverlight uses a familiar technique to go beyond the capabilities of standard web pages: a lightweight browser plug-in. The advantage of the plug-in model is that the user needs to install just a single component to see content created by a range of different people and companies. Installing the plug-in requires a small download and forces the user to confirm the operation in at least one security dialog box. It takes a short but definite amount of time, and it’s an obvious inconvenience. However, once the plug-in is installed, the browser can process any content that uses the plug C#.

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧