首页 > 开发 > 综合 > 正文

使用CustomValidator模仿show出一个confirm()

2024-07-21 02:15:45
字体:
来源:转载
供稿:网友


--------------aspx--------------------
function showmsg(ctl,args)
        {
            if(confirm(document.add.txt_title.value))
            {
                args.isvalid=true;
            }
            else
            {
                args.isvalid=false;
            }
        }
.................
<asp:textbox id="txt_title" runat="server" cssclass="stedit" width="240"></asp:textbox>
<asp:textbox id="txt_hidden" runat="server" cssclass="stedit" width="0" readonly="true"></asp:textbox>
..................
<asp:customvalidator id="customvalidator2" runat="server" onservervalidate="val2" clientvalidationfunction="showmsg" controltovalidate="txt_hidden" display="dynamic"></asp:customvalidator>
--------------------cs----------------------
...................
public void val2(object sender, servervalidateeventargs e)
        {
            e.isvalid=true;
        }
...................
private void page_load(object sender, system.eventargs e)
        {
...................
            if(!page.ispostback)
            {
                txt_hidden.text="init hidden textbox";
...................
            }
        }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表