我动态创建了一些 RadCombobox。用户选择后,我尝试从 RadComboBox 获取值。但我找不到控制。
这是我的代码:
ASP.NET:
<asp:Panel ID="pnlErsteMenuesAnlegenSchritt3" runat="server">
<ul runat="server" id="MenuAusMenuPunktenZusammengesetzt" class="MenuColletionPos">
</ul>
<telerik:RadButton ID="rtbnMenuElementeHrefEingabeVerarbeiten" runat="server" Text="Weiter" OnClientClicking="CollectMenuElementeWithHref"></telerik:RadButton>
</asp:Panel>
VB.net:
Public Sub MenuHrefAnlegen(ByVal endVal As Integer, ByVal strArrQuerystring As Array)
Dim width As String = "width:199px;"
Dim count As Integer = 1
Dim i As Integer
Dim startval As Integer
startval = 1
For i = startval To endVal
'erzeuge menü element
Dim combo As New RadComboBox()
combo.ID = "rcbHrefAuswaehlen" & count
combo.EnableLoadOnDemand = True
combo.Skin = "Metro"
combo.Items.Insert(0, New RadComboBoxItem("Über uns", String.Empty))
combo.Items.Insert(1, New RadComboBoxItem("Baufinanzierung", String.Empty))
combo.Items.Insert(2, New RadComboBoxItem("Denkmal-Immobilien", String.Empty))
combo.Items.Insert(3, New RadComboBoxItem("Photovoltaik", String.Empty))
combo.Items.Insert(4, New RadComboBoxItem("Assekuranz", String.Empty))
combo.Items.Insert(5, New RadComboBoxItem("Kontaktseite", String.Empty))
combo.Items.Insert(6, New RadComboBoxItem("Impressum", String.Empty))
combo.Items.Insert(7, New RadComboBoxItem("Benutzerdefinierte Seite", String.Empty))
Dim hfMenuElement As New HiddenField
hfMenuElement.ID = "hfMenuElement" + count.ToString()
hfMenuElement.Value = strArrQuerystring(count)
MenuAusMenuPunktenZusammengesetzt.Controls.Add(New LiteralControl("<li class=""floatKill""><a href=""#"" id=""hrefm" & count & """ runat=""server"" onmouseover=""menuov('menuleft" & count & "', 'menupuffer" & count & "', 'menuright" & count & "');"" onmouseout=""menuovf('menuleft" & count & "', 'menupuffer" & i & "', 'menuright" & count & "');""><div id=""menuleft" & count & """ class=""menu_left""></div><div id=""menupuffer" & count & """ class=""menu_puffer"" style=""" & width & """>" & strArrQuerystring(count) & "</div><div id=""menuright" & count & """ class=""menu_right""></div></a><div class=""pfeil links"" style=""margin-left:15px;margin-top:8px;""></div><div class=""pfeil links"" style=""margin-top:8px;""></div><div class=""pfeil links"" style=""margin-right:15px;margin-top:8px;""></div></li>"))
MenuAusMenuPunktenZusammengesetzt.Controls.Add(combo)
MenuAusMenuPunktenZusammengesetzt.Controls.Add(hfMenuElement)
count += 1
Next
End Sub
jQuery:
function CollectMenuElementeWithHref(sender, eventArgs) {
var VID = $('input[id$=hfVermittlerID]').val();
var obj = { ID: VID };
for (var i = 1; i < 9; i++) {
var hfVal = $('[id$=hfMenuElement' + i + ']').val();
//At this point i get Null back
var combo = $find("<%= rcbHrefAuswaehlen" + i + ".ClientID %>");
var item = combo.get_items().getItem(2);
if (hfVal) {
obj["pa" + i] = hfVal
obj["href" +1] = item.get_text()
}
}
eventArgs.set_cancel(true);
window.location.href = 'VermittlerBearbeiten.aspx?' + $.param(obj);
}
我总是得到 Null 回来。
var combo = $find("<%= rcbHrefAuswaehlen" + i + ".ClientID %>");
这与我如何创建此控件有关吗?我希望有人能帮助我。
谢谢大家阅读:)