使用javascript的asp.net [英] asp.net with javascript
问题描述
我有文本框,其文本通过选中的复选框项目分配
使用javascript。
我还有两个下拉列表,其值相互依赖,通过.cs分配c#中的服务器代码。
选择下拉值文本框值丢失。
如何保留文本框值?????
i已经使用了更新面板并在隐藏字段中保存复选框选中的值,然后在javascript中将其分配给文本框。
textbox是readonly
帮帮我
Javascript函数:
I have textbox whose text is assign through checkbox item selected
using javascript.
I also have two dropdown whose value is interdependent each other which is assign through .cs server code in c#.
while selecting dropdown value textbox value lost.
how i retain textbox value ?????
i already used update panel and save checkbox selected value in hidden field and then assign it to textbox in javascript.
textbox is readonly
help me
Javascript function:
<script type="text/javascript">
function Checkinternationallocation(checkBoxList) {
var options = checkBoxList.getElementsByTagName('input');
var arrayOfCheckBoxLabels = checkBoxList.getElementsByTagName("label");
var s = "";
for (i = 0; i < options.length; i++) {
var opt = options[i];
if (opt.checked) {
s = s + ", " + arrayOfCheckBoxLabels[i].innerText;
}
}
if (s.length > 0) {
s = s.substring(2, s.length); //sacar la primer 'coma'
}
var TxtBox = document.getElementById("<%=txt_combo_international_location.ClientID%>");
TxtBox.value = s;
document.getElementById('<%=hide_international_location.ClientID %>').value = s;
}
</script>
:文本框的html代码:
:html code for textbox:
<div class="rightPositioncontrol">
<asp:TextBox ID="txt_combo_location" runat="server" Width="450" onChange="tab();" ToolTip="Location(s) of Job"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender5" runat="server" TargetControlID="txt_combo_location"
WatermarkText="Select Location(s) of Jobs" WatermarkCssClass="watermarked" />
<cc1:PopupControlExtender ID="PopupControlExtender3" runat="server" TargetControlID="txt_combo_location"
PopupControlID="Panel_location" Position="Bottom">
</cc1:PopupControlExtender>
<input type="hidden" name="hide_location" id="hide_location" runat="server" />
<asp:Panel ID="Panel_location" runat="server" Width="450" Height="200px" ScrollBars="Vertical"
BackColor="AliceBlue" BorderColor="Gray" BorderWidth="1">
<asp:CheckBoxList ID="chk_location" CssClass="radio_button_txt" runat="server" Width="450"
onclick="Checklocation(this)">
</asp:CheckBoxList>
</asp:Panel>
</div>
提前感谢
thanks in advance
推荐答案
哪里是txt_combo_international_location?
我建议您在iis分析后检查aspx代码并将其显示给我们。
where is txt_combo_international_location ?
I advise that you check the aspx code after iis analysed and show it to us .
这篇关于使用javascript的asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!