如何将网格中的文本框ID分配给javascript函数

编程入门 行业动态 更新时间:2024-10-24 10:17:59
本文介绍了如何将网格中的文本框ID分配给javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

<script type=text/javascript; google.load("elements", "1", { packages: "transliteration" }); function onLoad() { var lang = document.getElementById("<%= hdnlang.ClientID %>").value; var options = { sourceLanguage: 'en', destinationLanguage: [lang], transliterationEnabled: true }; var control = new google.elements.transliteration.TransliterationControl(options); var ids = ["textboxid"]; control.makeTransliteratable(ids); control.showControl('translControl'); }

<td> <telerik:RadGrid ID="gvSettings" AllowSorting="false" AllowPaging="false" runat="server" CssClass="grid tBorder" ShowFooter="false" AllowMultiRowSelection="false" AllowMultiRowEdit="false" AllowFilteringByColumn="false" CellSpacing="0" CellPadding="0" AutoGenerateColumns="False" Skin="" Width="99%" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center" AlternatingItemStyle-HorizontalAlign="Left" HorizontalAlign="Center"> <footerstyle cssclass="gridfooter" /> <HeaderStyle HorizontalAlign="Center" CssClass="gridHeader"></HeaderStyle> <itemstyle horizontalalign="Left" cssclass="gridItem" height="30px"></itemstyle> <pagerstyle mode="NumericPages" cssclass="gridpage" position="Bottom" /> <alternatingitemstyle horizontalalign="Left" cssclass="gridAltItem" height="30px"> </alternatingitemstyle> <filteritemstyle cssclass="gridFliterItem" /> <SelectedItemStyle CssClass="gridSelectedItem" /> <commanditemstyle cssclass="gridCommandItem" /> <mastertableview> <columns> <telerik:gridtemplatecolumn headertext="Template Text" itemstyle-width="50%" uniquename="Text" xmlns:telerik="#unknown"> <itemtemplate> <asp:TextBox ID="txtTemplateText" runat="server" /> </itemtemplate> <itemstyle width="50%" /> </telerik:gridtemplatecolumn> </columns> <editformsettings> <editcolumn filtercontrolalttext="Filter EditCommandColumn column"> </editcolumn> </editformsettings> </mastertableview> <filtermenu enableimagesprites="False"> </filtermenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_"> </HeaderContextMenu> </td>

我想将网格文本框ID(txtTemplateText)传递给Javascript函数 var ids = [textboxid ]。怎么做..

I want to pass the Grid Textbox id(txtTemplateText) to the Javascript Function var ids = ["textboxid"]; how to do it..

推荐答案

您应该查看标记,以获取有关页面结构的线索。 Javascript只会在页面呈现后运行。 在ClientId等的情况下,它们是在运行时在telerik网格和页面或控件中生成的代码隐藏没有意识到它们。你可以找到它们但输出到javascript中并不是一件容易的事。 最好的方法是使用jQuery。它提供扩展功能并使JS变得更加容易: 如果查看呈现页面上的源代码,您将看到文本框的客户端ID可能结束类似于... _ gvSettings_txtTemplateText_0 你可以使用jQuery快速找到所有这些使用id contains(id * ='')选择器: You should look at the markup for clues on how the page is structured. Javascript will only ever run after the page has been rendered. In the case on ClientId's et al, They are generated at runtime in the telerik grid and the Page or Control codebehind is not made aware of them. You can find them but outputting this into javascript is no mean feat. The best way would be to use jQuery. It offers extension functions and makes JS so much easier: If you look at the source on the rendered page, you will see that the client id of the textboxes might end with something like ..._gvSettings_txtTemplateText_0 You can use jQuery to find all of these very quickly using the id contains (id*='') selector: var textboxes =

( 输入[id * ='gvSettings_txtTemplateText'])

结果在'textboxes'将是文本框元素的数组。 这里有一篇很好的文章从jQuery开始: jQuery for Beginners [ ^ ] 一旦有了这些文本框,就可以使用jquery轻松添加一个函数:

The result in 'textboxes' will be an array of the textbox elements. There is a good article for starting with jQuery here: jQuery for Beginners[^] Once you have these textboxes, adding a function to them is easy with jquery:

textboxes.change(function(){ var textboxBeingChanged = this; var newVal = textboxBeingChanged.val(); });

更多推荐

如何将网格中的文本框ID分配给javascript函数

本文发布于:2023-11-10 00:43:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573899.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   如何将   文本框   函数   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!