点击按钮弹出 确认 取消对话框. 确认就执行,取消就是不执行.
我要写在xxxx.aspx.vb上的代码
不要aspx上的.
另外,出现对话框后的页面的字体怎么自动改变了呢?
我要写在xxxx.aspx.vb上的代码
不要aspx上的.
另外,出现对话框后的页面的字体怎么自动改变了呢?
解决方案 »
- asp登陆后session立刻丢失,直接返回到登陆页面
- GridView问题
- 到哪里下载Ajax.net的控件
- cache 简单问题。
- 如何使一个自定义控件可以嵌套,即可以包含其它子控件?像form那样
- asp.net与wpf的代码隐藏(codebehind)设计思想是一样的吗?
- 我在本机调试的很好,可是传到服务器就显示(未能加载类型“newsoft.index”),详细见内。
- 我编的最新软件---代码助手
- 模板列问题 在线等给分
- 我用datatable填充datagrid。。。。。(一定给分!!)
- asp.net 中如何实现将word文档转换成html来显示
- 用JAVA做网页和asp.net有什么不同,有什么好的方面?
字体改变不要,除非自己用div模拟。
否则可以写在pageload里
private void page_load()
{
this.Button1.Attributes.Add("onclick","javascript:return confirm('要提交吗?');");
}
this.Button1.Attributes.Add("onclick","javascript:return confirm('要提交吗?');");
但是应该加一个条件if(!Ispostback)
{
this.Button1.Attributes.Add("onclick","javascript:return confirm('要提交吗?');");
}
这个解已经有了,谢谢各位.
现在的问题是为什么第一次点击按钮不弹出对话框,第2次才弹出?
this.Button1.Attributes.Add("onclick","javascript:return confirm('要提交吗?');");
字体改变不要,除非自己用div模拟。楼上:
楼主字体之所以改变,是因为使用了Response.Write()把js输出了吧,这样破坏了页面的结构导致CSS失效。--------------------------
up
Button1.Attributes.Add("onclick", "if ( confirm('Are you sure?') != true ) return false;")Another way, if you have to have the results server-side is:
In the aspx file:
<input type="hidden" id="Hidden1" name="Hidden1" runat="server">
That adds this to the CodeBehind:
Protected WithEvents Hidden1 As System.Web.UI.HtmlControls.HtmlInputHiddenThen add to the Page_Load event handler:Dim scriptString As String = "<script language=JavaScript> " + Environment.NewLine
' Store the confirm's return in the hidden control...
scriptString += "document.getElementById('" + Hidden1.ClientID + "').value = " + Environment.NewLine
scriptString += " confirm('Are you sure?'');" + Environment.NewLine
' Do a new PostBack...
scriptString += GetPostBackEventReference(Hidden1, String.Empty) + ";" + Environment.NewLine
scriptString += "</script>"RegisterStartupScript("ConfirmScript", scriptString)If IsPostBack AndAlso Request("__EVENTTARGET") = "Hidden1" Then
If Hidden1.Value = "true" Then
' User answered OK
Else
' User answered Cancel
End If
End If
Hidden1.Value = String.Empty