刷新页面数据丢失(高手勿进)

来源:互联网 发布:学会计哪个软件好 编辑:程序博客网 时间:2024/06/05 16:23

文本框通过js脚本获取时间,刷新页面之后文本框里的数据会出现丢失的现象,

解决办法是获取该控件的值,然后将值再赋给该控件。

前台:  <td class="fieldNameTd" align="right" style="width: 120px; height: 15px;">
                            开工日期:
                        </td>
                        <td class="fieldValueTd">
                            <asp:TextBox ID="TextStartTime" runat="server" Style="width: 160px;" MaxLength="50"
                                onclick="new Calendar().show(this);" ReadOnly="True"></asp:TextBox>
                        </td>
                        <td class="fieldNameTd" align="right">
                            竣工日期:
                        </td>
                        <td class="fieldValueTd">
                            <asp:TextBox ID="TextCompletedTime" runat="server" Style="width: 160px;" MaxLength="50"
                                onclick="new Calendar().show(this);" ReadOnly="True"></asp:TextBox>
                        </td>

后台:  string StartTime = this.Request.Form[this.TextStartTime.UniqueID].ToString().Trim();
            string CompletedTime = this.Request.Form[this.TextCompletedTime.UniqueID].ToString().Trim();
            this.TextStartTime.Text = StartTime;
            this.TextCompletedTime.Text = CompletedTime;

原创粉丝点击