I show a modalpopupextender using javascript, and when I click its save button, it saves the things I have input in, and (as its a button) postsback automatically so the page refreshes.
However when it refreshes, I get an error because it says the checkbox control I define on my aspx page is null.
One of the first things I do when the page loads is create some javascript and feed in various clientIDs for my components, and the last one to be added is chkFullyBooked.ClientID.
When the page loads the first time, it is ok, but after posting back it says my checkbox is null.
Another issues is that in my save button function, while it can retreive the value of textboxes and the checkbox in code, it cannot get the text from labels that have changed... I got around this by converting my labels to textboxes though.
I just cannot figure out the reason why the checkbox control (hard-coded into my page with other textboxes) would come back as null on a page refresh.
Code at the top of my aspx page:
<% Response.Write("<script language='javascript' type='text/javascript'>" +
"function DisplayModalPopup(dateCreated, note, editedBy, fullybooked) {" +
"var modalDialog = $find('AddressErrorPopup');" +
"document.getElementById('" + txtNote.ClientID + "').value = note;" +
"if (modalDialog != null) { modalDialog.show(); }" +
"var lblLastEditBy = document.getElementById('" + txtLastEditBy.ClientID + "');" +
"lblLastEditBy.value = editedBy;" +
"var lblDateCreated = document.getElementById('" + txtTallyBoardEntryDate.ClientID + "');" +
"lblDateCreated.value = dateCreated;" +
"var fullyBooked = document.getElementById('" + chkFullyBooked.ClientID + "');" +
"fullyBooked.value = fullybooked;" +
"} " +
"</script>"); %>
Later on in my code, an excerpt:
.
.
.
<tr>
<td colspan="2" style="text-align:left">Last Edit by - <asp:TextBox ID="txtLastEditBy" ReadOnly="true" runat="server"></asp:TextBox></td>
</tr>
<tr><td colspan="2" style="text-align:left"><asp:CheckBox runat="server" ID="chkFullyBooked" Text="Fully Booked?" Checked="false"/></td></tr>
.
.
.
Edit: This of course means I get a null reference exception on the code above as it cannot access ClientID.
Edit: As a crappy fix I did response.redirect(request.url.tostring) instead of letting the button postback itself, and this for some godforsaken reason works fine..