Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

WebForms and Javascript Question

$
0
0

I spent hours looking at this code without any progress... this could be a simple fix but I just need somebody to OPEN my eyes WIDER.

Basically what Im doing is whenever the client select event is fired on a dropdownlist,  im using javascript to automatically populate a ASP.NET TextBox Server control based on the selected value.  But when I try to submit and do a postback, the textbox does not get any values and just return an empty string.

$('select').change(function () {
var num = ($(this).attr('id').replace('Row', '').replace('QuestionTypeDropDownList', ''));
var isTrueOrFalse = $('#Row' + num + 'QuestionTypeDropDownList :selected').text() === "True Or False";
if (isTrueOrFalse) {
$("#Row" + num + "NumberOfAnswersTextBox").val(2); //LETS DEFAULT FOR TRUE AND FALSE
$("#Row" + num + "NumberOfAnswersTextBox").spinner('disable');
} else {
$("#Row" + num + "NumberOfAnswersTextBox").val(0);
$("#Row" + num + "NumberOfAnswersTextBox").spinner('enable');
}
});

HERE IS THE ASPX CODE

<tr>
<td class="center"><asp:DropDownList runat="server" ID="Row1QuestionTypeDropDownList" CssClass="question-type-dropdown" ClientIDMode="Static"></asp:DropDownList></td>
<td class="center"><asp:TextBox runat="server" ID="Row1NumberOfAnswersTextBox" ClientIDMode="Static"></asp:TextBox></td>
<td class="center"><asp:TextBox runat="server" ID="Row1NumberOfQuestionsTextBox" ClientIDMode="Static"></asp:TextBox></td>
<td class="center"><a href="#" class="buttonM bDefault add-question-group-button"><span class="icos-add"></span><span>Add Question Group</span></a></td>
</tr>


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>