2个回答
2013-06-26
展开全部
请先了解一下AJAX相关知识,你这个需求需要一个异步调用。以下是只用javscript来实现,你也可以使用jquery之类的其他类库///创建异步调用对象///
function GetHttpObject()
{
var XHRequest = false;
try
{ XHRequest = new XMLHttpRequest(); }
catch(e)
{
try
{ XHRequest = new ActiveXObject("MSXML2.XMLHTTP.3.0"); }
catch(e)
{
try
{ XHRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e)
{ XHRequest = false; }
}
}
if (!XHRequest)
{ alert("创建对象失败,请刷新页面重试"); }
return XHRequest;
}var XHRequest = GetHttpObject();
function GetReturnValue()
{if (XHRequest.readyState == 4)
{
var returnStr = XHRequest.responseText;
if(returnStr.charAt(0) == "1")//登录成功在后台Response.Write("1") { 登录成功刷新页面或是隐藏登录层等操作。 }else{登录失败的操作}}XHRequest.open("Post", 后台处理页面地址, true);
XHRequest.onreadystatechange = GetReturnValue;
XHRequest.send(null);后台怎么处理你应该会吧。重点就是成功了Response.Write("1")或是其他字符,失败Response.Write("2")或是其他字符。
function GetHttpObject()
{
var XHRequest = false;
try
{ XHRequest = new XMLHttpRequest(); }
catch(e)
{
try
{ XHRequest = new ActiveXObject("MSXML2.XMLHTTP.3.0"); }
catch(e)
{
try
{ XHRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e)
{ XHRequest = false; }
}
}
if (!XHRequest)
{ alert("创建对象失败,请刷新页面重试"); }
return XHRequest;
}var XHRequest = GetHttpObject();
function GetReturnValue()
{if (XHRequest.readyState == 4)
{
var returnStr = XHRequest.responseText;
if(returnStr.charAt(0) == "1")//登录成功在后台Response.Write("1") { 登录成功刷新页面或是隐藏登录层等操作。 }else{登录失败的操作}}XHRequest.open("Post", 后台处理页面地址, true);
XHRequest.onreadystatechange = GetReturnValue;
XHRequest.send(null);后台怎么处理你应该会吧。重点就是成功了Response.Write("1")或是其他字符,失败Response.Write("2")或是其他字符。
2013-06-26
展开全部
你是说一些非空的验证弹出窗口提示吗?如果是的话这样写: protected void btnSubmit_Click(object sender, EventArgs e)
{
if((txtName.Text.Trim()) == "" || (string.IsNullOrEmpty(txtName.Text.ToString()) == true))
{
Response.Write("<script>alert('用户名为空')</script>");
}else {
Response.Write("<script>alert('北大青鸟欢迎您!')</script>");
}
}
{
if((txtName.Text.Trim()) == "" || (string.IsNullOrEmpty(txtName.Text.ToString()) == true))
{
Response.Write("<script>alert('用户名为空')</script>");
}else {
Response.Write("<script>alert('北大青鸟欢迎您!')</script>");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询