Addning scrip while using UpdatePanel?
-
Is is somehow possible to add a script using UpdatePanel? My problem is that I have a DataGrid containg 2 couloms with 1 TextBox in each. On the first TextBox there is an OnTextChangeEvent with an AutoPostBack="true", and in this function I add scripts to set focus, and select the text on the next TextBox as in:
private void OnSubscriptionFromValueChanged(object sender, System.EventArgs e) { TextBox tb = (TextBox)sender; DataGridItem dgi = (DataGridItem)tb.Parent.Parent; TextBox tbToFocus = (TextBox)dgi.FindControl("tbToValue"); Page.ClientScript.RegisterStartupScript(GetType(), "focus", "document.getElementById('" + tbToFocus.UniqueID + "').focus();"); Page.ClientScript.RegisterStartupScript(GetType(), "select", document.getElementById('" + tbToFocus.UniqueID + "').select();"); .. ... .... }
This works fine. But then I added an UpdatePanel around the DataGrid, as inasp:UpdatePanel ID="upSubscription" runat="server"> <ContentTemplate> <asp:datagrid id="dgSubscription" runat="server" CssClass="grid" AllowPaging="False" CellPadding="0" GridLines="Vertical" AutoGenerateColumns="False" ShowFooter="true" OnItemCreated="dgSubscription_ItemCreated"> asp:TemplateColumn HeaderText="From value" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px"> ItemTemplate> asp:TextBox id="tbFromValue" runat="server" AutoPostBack="true" CssClass="tbStyle0" Text='<%#DataBinder.Eval(Container.DataItem, "decFromValue").ToString()%>'> </asp:TextBox> /ItemTemplate> /asp:TemplateColumn> <asp:TemplateColumn HeaderText="To value" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="150px"> ItemTemplate> asp:TextBox id="tbToValue" runat="server" AutoPostBack="true" CssClass="tbStyle0" Text='<%#DataBind