【问题标题】:Set a ViewState using JQuery使用 JQuery 设置 ViewState
【发布时间】:2013-09-13 13:58:45
【问题描述】:

我有一个 GridView 的 CustomWebUserControl 并移动我使用 ViewState 的项目,现在我需要在单击行时移动 SelectedIndex,过程将是:

  1. 点击预期的行;
  2. 在currentItemTextBox.Text中设置rowIndex的值;
  3. 该值将使用 TextChanged 事件在 ViewState 上输入;
  4. 我将为我的 GridView 调用 DataBind 到我的内部方法,使用此 ViewState 选择 currentRow。
<script type="text/javascript">
     $(document).ready(function () {
        $("#<%=mainGridView.ClientID%> tr").click(function () {
            var ind = $(this).index();
            $("#<%=currentIndexTexBox.ClientID%>").val(ind);
        });
    });
</script>

*当脚本设置值时,TextChanged 事件不会被调用。

希望你能看懂我的场景。在这里输入代码

谢谢!

【问题讨论】:

    标签: c# jquery asp.net webforms


    【解决方案1】:

    尝试在您的文本框中添加 AutoPostBack="True"。这将调用 OnTextChanged 事件。

        <asp:TextBox ID="currentIndexTexBox" runat="server" OnTextChanged="CurrentIndexTextBoxOnTextChanged()" AutoPostBack="True"></asp:TextBox>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多