0

我在一个页面上有三个 RadListBox 控件。当用户将一个项目从第一个列表框拖到第二个列表框时,我需要第三个来自动生成一个文本框。

我已经弄清楚如何使用 JavaScript 添加常规的 HTML 文本框。但是,我无法在页面后面的代码中访问它,因为添加runat=server字段会导致错误。这是我用来插入文本框的客户端 JavaScript 代码:

//Add textbox to 3rd listbox    
var listbox = $find("<%= ListBoxThree.ClientID %>");
listbox.trackChanges();
var textboxItem = new Telerik.Web.UI.RadListBoxItem();
textboxItem.set_text(item.get_text()); //sets the ID
textboxItem.set_clientTemplate("  <input id=\"#= Text #\" type=\"text\" /> ");
textboxItem.bindTemplate();
textboxItem.set_value
listbox.get_items().add(textboxItem);
listbox.commitChanges();

如果我尝试添加runat=server,则会收到以下错误:

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
Line 70:                     textboxItem.set_clientTemplate("  <input id=\"#= Text #\" type=\"text\" runat=\"server\" /> ");

解析器错误消息:服务器标记格式不正确。

但是,当用户点击 Save 按钮时,项目的 Text 和 Value 字段不会更新为他们输入的文本。

    protected void SaveButton_Click(object sender, EventArgs e)
    {

        foreach (RadListBoxItem item in ListBoxThree.Items)
        {
            string value = item.Value;
            string text = item.Text;
        }
    }

如果有人能指出我正确的方向,我将不胜感激!

4

0 回答 0