ReadOnly=True 后台取不到新值

<asp:repeater id="DataGrid_HotList" runat="server">
    <ItemTemplate>
         <asp:textbox id="d_sortno" runat="server" Width="30px" ReadOnly=True Text='<%# Container.ItemIndex + 1 %>'></asp:textbox>
    </ItemTemplate>
</asp:repeater>

用js 修改 d_sortno 的排序,在页面上调试,弹出提示,显示都是对的

按钮提交后获取 d_sortno 的编号,发现怎么获取都是原来的数据,新修改的取不到,调试了一上午未果,突然把 ReadOnly=True 去掉后,可以了,我就郁闷了~~~~~~~~~~

解决方案

textbox的 ReadOnly="true" 经由js改变textbox里面的值,在后台处理代码还是页面初始时的值。解决这个题目办法就是在

在后台IsPostBack里面加Attributes.Add("readonly", "true")。

原文地址:https://www.cnblogs.com/dj1232090/p/2208635.html