您的位置:程序门 -> web 开发 -> asp



我在aspx.cs文件里在html页面上加了一个textbox ,怎么用asp:requiredfieldvalidator对这个控件进行非空值检验


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


我在aspx.cs文件里在html页面上加了一个textbox ,怎么用asp:requiredfieldvalidator对这个控件进行非空值检验[已结贴,结贴人:ljlion]
发表于:2007-02-13 11:08:37 楼主
我在aspx.cs文件里在html页面上加了一个textbox   ,怎么用asp:requiredfieldvalidator对这个控件进行非空值检验

textbox   txt_date   =   new   textbox();
        txt_date.id   =   "date ";
        txt_date.causesvalidation   =   true;
panel.controls.add(txt_date);

发表于:2007-02-13 12:16:031楼 得分:0
好像在右侧的属性中设置
发表于:2007-02-13 15:25:592楼 得分:0
能不能具体点啊。。。。。。。。。。。。。。
发表于:2007-02-13 23:28:453楼 得分:0
拖一个requiredfieldvalidator控件到web窗体中。
再在requiredfieldvalidator控件的属性中选择它要验证的控件。
发表于:2007-02-14 00:23:464楼 得分:0
<%@   page   language= "c# "   autoeventwireup= "true "   %>
<!doctype   html   public   "-//w3c//dtd   xhtml   1.0   transitional//en "   "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "content-type "   content= "text/html;   charset=utf-8 "   />
<title> shawl.qiu   template </title>
<script   runat= "server ">
  void   btn_clk(object   s,   eventargs   e)
  {
    if(page.isvalid&&tbx.text!= " ")
    {
      lbl.text= "field   valid. ";
    }
    else
    {
      lbl.text= "field   invalid. ";
    }
  }   //   end   page_load
</script>
</head>
<body>
  <form   runat= "server ">
    <asp:label   id= "lbl "   runat= "server "   />
    <li/>
      <asp:textbox   id= "tbx "   runat= "server "   />
    <li/>
      <asp:button   runat= "server "
        onclick= "btn_clk "
        text= "go   validate "
        />
      <asp:requiredfieldvalidator   runat= "server "
        controltovalidate= "tbx "
        />
  </form>
</body>
</html>
发表于:2007-02-14 00:58:305楼 得分:50
再加一个验证控件. requiredfieldvalidator   req   =   new   requiredfieldvalidator(); req.controltovalidate   =   "date "; panel.controls.add(req);
发表于:2007-02-14 12:17:516楼 得分:0
同意


快速检索

最新资讯
热门点击