在asp.net中,当页面刷新时控件中显示的都是上次的记录,比如,文本框中是上次输入的东西,还有单选框和复选框也都是上次选中的,怎么才可以在页面刷新时就让他们全部清空呢?请高手指点,谢谢~~

解决方案 »

  1.   

    你用的是服务端控件吗?/
    你取消他的ViewState
    试试!设ViewState=False不过这样会不太正常!还可像CSdn这样
    http://community.csdn.net/Expert/topic/3506/3506693.xml?temp=.8697321加一个无用的参数3506693.xml?temp=.8697321
      

  2.   

    源程序在如下:<%@ Page Language="C#" Debug="true" ContentType="text/html" ResponseEncoding="gb2312" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <script runat="server">
    protected void Page_Load(Object Src, EventArgs E)
    {
      
    }
    </script>
    <script runat="server">
    protected void ok_Click(Object Src, EventArgs E)
    {
     
       string[] answer=new string[]{"A","B","C","D","D","AB"};
       string[] t=new string[6];
       t[0]=t1.SelectedItem.Value;
       t[1]=t2.SelectedItem.Value;
       t[2]=t3.SelectedItem.Value;
       t[3]=t4.SelectedItem.Value;
       t[4]=t5.SelectedItem.Value;
       int score=0;
       for(int j=0;j<t6.Items.Count-1;j++)
       {
        if(t6.Items[j].Selected)
    t[5]=t[5]+t6.Items[j].Value;
       }
       for(int i=0;i<6;i++)
       {
        if(answer[i]==t[i])
    score=score+10;
       }
      message.Text="您的成绩是:"+Convert.ToString(score);
      
    }
    </script>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>在线考试系统</title>
    </head>
    <body>
    <form name="form1" method="post" runat="server">
      <p>1
        <asp:RadioButtonList ID="t1" runat="server" TextAlign="left">
       <asp:Listitem Value="A">A.</asp:ListItem>
    <asp:Listitem Value="B">B.</asp:ListItem>
    <asp:Listitem Value="C">C.</asp:ListItem>
    <asp:Listitem Value="D">D.</asp:ListItem>
      </asp:RadioButtonList>
      </p>
      <p>2.<asp:RadioButtonList ID="t2" runat="server" TextAlign="left">
       <asp:Listitem Value="A">A.</asp:ListItem>
    <asp:Listitem Value="B">B.</asp:ListItem>
    <asp:Listitem Value="C">C.</asp:ListItem>
    <asp:Listitem Value="D">D.</asp:ListItem>
           </asp:RadioButtonList></p>
      <p>3.<asp:RadioButtonList ID="t3" runat="server" TextAlign="left">
       <asp:Listitem Value="A">A.</asp:ListItem>
    <asp:Listitem Value="B">B.</asp:ListItem>
    <asp:Listitem Value="C">C.</asp:ListItem>
    <asp:Listitem Value="D">D.</asp:ListItem>
    </asp:RadioButtonList></p>
      <p>4.<asp:RadioButtonList ID="t4" runat="server" TextAlign="left">
           <asp:Listitem Value="A">A.</asp:ListItem>
    <asp:Listitem Value="B">B.</asp:ListItem>
    <asp:Listitem Value="C">C.</asp:ListItem>
    <asp:Listitem Value="D">D.</asp:ListItem>
    </asp:RadioButtonList></p>
      <p>5.<asp:RadioButtonList ID="t5" runat="server" TextAlign="left">
      <asp:Listitem Value="A">A.</asp:ListItem>
      <asp:Listitem Value="B">B.</asp:ListItem>
      <asp:Listitem Value="C">C.</asp:ListItem>
      <asp:Listitem Value="D">D.</asp:ListItem>
      </asp:RadioButtonList></p>
      <p>6.<asp:CheckBoxList ID="t6" runat="server" TextAlign="left">
    <asp:Listitem Value="A">A.</asp:ListItem>
    <asp:Listitem Value="B">B.</asp:ListItem>
    <asp:Listitem Value="C">C.</asp:ListItem>
    <asp:Listitem Value="D">D.</asp:ListItem>
            </asp:CheckBoxList></p>
      <p align="center"><asp:Button ID="tijiao" Text="交卷" OnClick="ok_Click" runat="server"/></p>
      <asp:label ID="message" runat="server"/>
    </form>
    </body>
    </html>
      

  3.   

    你可以在cs代码中写如下代码:
    TextBOx.text = "";
    不就可以了吗?