如何实现WEB页面对话框 在页面上按钮按下的时候,需要检验几个输入框的内容是否为空,如果为空,就弹出对话框提示,页面不跳转,如何实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 .net 自带有这个控件,叫 RequiredFieldValidator 吧帮你实现了这个功能,实际上就是帮你实现 java script ,你打开 .net 2003 看看,服务器工具2003 就开始有了 <script>function checkNum(){ var value1 = document.getElementById("txtNum1").value; var value2 = document.getElementById("txtNum2").value; var value3 = document.getElementById("txtNum3").value; var value4 = document.getElementById("txtNum4").value; if(value1 != "" && value2 != "" && value3 != "" && value4 != "") { window.Open("页面2.aspx"); } else { alert("请将数据输入完整!"); }}</script><body> <input type = "text" id = "txtNum1" /><br> <input type = "text" id = "txtNum2" /><br> <input type = "text" id = "txtNum3" /><br> <input type = "text" id = "txtNum4" /><br> <input type = "button" onclick = "checkNum()" /></body>以上是JS写法,一下是C#写法public void checkNum(){ string num1 = txtNum1.Text.Trim(); string num2 = txtNum2.Text.Trim(); string num3 = txtNum3.Text.Trim(); string num4 = txtNum4.Text.Trim(); if(num1.Equals("") || num2.Equals("") || num3.Equals("")) || num4.Equals("")) { Response.Write("<script>alert('请将数据输入完整!');</script>"); } else { Response.Redirect("页面2.aspx"); }} page_load 中btn.Attributes.Add("onclick","return checkform();");js:function checkform(){if(为空) return false;return true;} 求一个SQL 急 aspxgridview的使用 数据库的行存取 调用DLL的问题50分 [求教]Crystal report的部署问题 如何实现全选功能(按纽在模板列中)和如何实现模板列事件的疑问。 在C#中设断点的问题 控件的 invoke是将多线程里的操作回调到主线程里操作吗? 高分求解:在生成强类型dataset时,为何数据库中视图不能添加更新插入删除语句,只能查询? 做一个类似password的输入框,但要求能输入非数字字符,如何处理? 线程问题 求助,TreeView的显示问题
帮你实现了这个功能,实际上就是帮你实现 java script ,你打开 .net 2003 看看,服务器工具
2003 就开始有了
function checkNum()
{
var value1 = document.getElementById("txtNum1").value;
var value2 = document.getElementById("txtNum2").value;
var value3 = document.getElementById("txtNum3").value;
var value4 = document.getElementById("txtNum4").value;
if(value1 != "" && value2 != "" && value3 != "" && value4 != "")
{
window.Open("页面2.aspx");
}
else
{
alert("请将数据输入完整!");
}
}
</script>
<body>
<input type = "text" id = "txtNum1" /><br>
<input type = "text" id = "txtNum2" /><br>
<input type = "text" id = "txtNum3" /><br>
<input type = "text" id = "txtNum4" /><br>
<input type = "button" onclick = "checkNum()" />
</body>
以上是JS写法,一下是C#写法
public void checkNum()
{
string num1 = txtNum1.Text.Trim();
string num2 = txtNum2.Text.Trim();
string num3 = txtNum3.Text.Trim();
string num4 = txtNum4.Text.Trim();
if(num1.Equals("") || num2.Equals("") || num3.Equals("")) || num4.Equals(""))
{
Response.Write("<script>alert('请将数据输入完整!');</script>");
}
else
{
Response.Redirect("页面2.aspx");
}
}
function checkform(){
if(为空) return false;
return true;
}