asp.net弹出信息框——没有用ScriptManager

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cyy089074316/article/details/6749297
 

一、弹出确认信息(1——3)

1、Response.Write("<script>alert('背景变白!');</script>");

这种方法当弹出消息框时背景会变白

2、

 Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('背景没有变白!');</script>");

3、

//.NET在后置代码中输入JS提示语句(背景不会变白)

  Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('加入暂存架成功!');</script>");

  //有转向

  Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('恭喜您,修改成功!');window.location='Default.aspx'</script>");   类似于AJAX的效果,页面不刷新!!!

二、弹出选择信息

(1) 点击页面上的按钮,弹出一个对话框提示是“确定”还是“取消”操作,我们采用在按钮中添加属性来完成:
     举例如下:
    public System.Web.UI.WebControls.Button btnDelRow;
    btnDelRow.Attributes.Add("onclick", "return confirm('
确定要删吗?');");

    (2) 点击页面上的按钮,弹出一个对话框提示是“确定”还是“取消”操作,选择“确定”或“取消”后跳转到相应的页面:

     举例如下:
       string strMsg, string strUrl_Yes, string strUrl_No;
       Response.Write("<Script Language='JavaScript'>if ( window.confirm('"+strMsg+"')) { window.location.href='" + strUrl_Yes +
                              "' } else {window.location.href='"+ strUrl_No +"' };</script>");

    (3) 对于页面完成一个操作后,弹出一个对话框提示是否“操作成功”。
     举例如下:
    Response.Write("<script>alert('删除成功!')</script>");

    (4) 对于页面完成一个操作后,弹出一个对话框提示是否“操作成功”后跳转到某一个页面。

     举例如下:
    Response.Write("<script>alert('删除成功!');window.location.href ='www.cnblogs.com'</script>");

    (5)允许 ASP.NET 服务器控件在 Page 中发出客户端脚本块:
    public virtual void RegisterStartupScript(string key,string script);

    举例如下:
    if(!this.IsStartupScriptRegistered("hello"))
        this.RegisterStartupScript("hello","<script>alert('
你好!')</script>");  

展开阅读全文

asp.net scriptmanager调用webservice

03-11

[code=JScript]rn// JScript 文件rnrn//注册窗体jsrnvar regs = new Array();rnvar validateInputsOk = new Array();rnvar tipses = new Array();rnvar isgood = false;rnregs['txt_uid']=/^[a-zA-Zu4e00-u9fa5]5,20$/;rnregs['txt_pwd']=/\w6,18/;rnregs['txt_email'] = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;rnvalidateInputsOk['uid'] = false;rnvalidateInputsOk['pwd'] = false;rnvalidateInputsOk['pwdconfirm'] = false;rnvalidateInputsOk['email'] = false;rntipses['txt_uid'] = '请输入正确的用户名';rntipses['txt_pwd'] = '请输入正确的密码,长度在6-18之间';rntipses['txt_pwdconfirm'] = '确认密码有错';rntipses['txt_email'] = '请输入正确的email';rntipses['right'] = '\u221a';rnfunction username_isuse(username) rn return WebService.ValidateUserName(username,UserNameResult);rnrnfunction UserNameResult(response)rn if(response)rn rn $('tips_username').innerHTML = tipses['right'];rn elsern $('tips_username').innerHTML ="该用户已经存在";rn $('tips_username').style.color = 'red';rn rnrnfunction email_isuse(email) rn WebService.ValidateEmail(email,EmailResult);rnrnfunction EmailResult(response)rn if(response)rn rn $('tips_email').innerHTML = tipses['right'];rn elsern $('tips_email').innerHTML ="该邮箱已经存在";rn $('tips_email').style.color = 'red';rn validateInputsOk['email'] =false;rn rnrnfunction username_blur() rn var username = $('txt_uid').value;rn var usernameOk = usernameValidate(username);rn rn validateInputsOk['uid'] = usernameOk;rn rn if(!usernameOk) rn $('tips_username').innerHTML = tipses['txt_uid'];rn $('tips_username').style.color = 'red';rn else rn username_isuse(username);rn $('tips_username').style.color = '';rn rnrnrnfunction password_blur() rn var password = $('txt_pwd').value;rn var passwordOk = passwordValidate(password);rn rn validateInputsOk['pwd'] = passwordOk;rn rn if(!passwordOk) rn $('tips_password').innerHTML = tipses['txt_pwd'];rn $('tips_password').style.color = 'red';rn else rn $('tips_password').innerHTML = tipses['right'];rn $('tips_password').style.color = '';rn rnrnrnfunction repassword_blur() rnrn var password = $('txt_pwd').value;rn var repassword = $('txt_pwdconfirm').value;rn var repasswordOk = repasswordValidate(password, repassword);rn rn validateInputsOk['pwdconfirm'] = repasswordOk;rn rn if(!repasswordOk) rn $('tips_repassword').innerHTML = tipses['txt_pwdconfirm'];rn $('tips_repassword').style.color = 'red';rn else rn $('tips_repassword').innerHTML = tipses['right'];rn $('tips_repassword').style.color = '';rn rnrnrnfunction email_blur() rn var email = $('txt_email').value;rn var emailOk = emailValidate(email);rn rn validateInputsOk['email'] = emailOk;rn rn if(!emailOk) rn $('tips_email').innerHTML = tipses['txt_email'];rn $('tips_email').style.color = 'red';rn else rn email_isuse(email);rn $('tips_email').style.color = '';rn rnrnrnfunction usernameValidate(username) rn return regs['txt_uid'].test(username);rnrnrnfunction passwordValidate(password) rn return regs['txt_pwd'].test(password);rnrnrnfunction repasswordValidate(password, repassword) rn if(repassword=='' || password =='')rn return false;rn elsern return password == repassword;rn rnrnrnfunction emailValidate(email) rn return regs['txt_email'].test(email);rnrn/*提交验证*/rnfunction submitValidate() rn username_blur();rn password_blur();rn repassword_blur(); rn email_blur();rn rn if(!validateInputsOk['uid'])rn return false;rn rn if(!validateInputsOk['pwd'])rn return false;rn rn if(!validateInputsOk['pwdconfirm'])rn return false;rn rn if(!validateInputsOk['email'])rn return false;rn rn return true;rnrn[/code]rn这个是用来注册校验的代码。rn这里的问题是:rnsubmitValidate()里面执行完了,才去执行UserNameResult。rn我需要在执行username_blur()的时候,就执行rnUserNameResult()。 论坛

没有更多推荐了,返回首页