Mysterious postback issues with javascript (asp.net) -


I show a model poppadxtender using javascript, and when I click on the save button it Saves things to me, and as a button in it) automatically refreshes the page.

While it refreshes, I get an error because it says that the checkbox control defined on my ASPX page is zero.

One of the first things I do when page loads make some components and feeds in different client IDs for my components, and the last one can be added chkFullyBooked.ClientID.

When the page loads for the first time, it's okay, but after posting it says that my checkbox is empty.

Another issue is that in my Save button function, while this can change the value of the text box and the checkbox in the code, the text has changed from the labels ... Converted to box and found around it.

I did not know why the checkbox is the control (hard-code in my page

code at the top of my aspx page:

  & Lt;% Response.Write (with "other text box") script language = 'javascript' type = 'text / javascript' & gt; "+" function display model popup (date cratted, note, edited) , Is fully booked) {"+" Var Model Diialog = $ (Find 'AddressAreop'); "+" document.getElementById ('+ + TxtNote.ClientID +' ') .val Ue = Note; "+" if (modelDialog! = Null) {modalDialog.show ();} "+" var lblLastEditBy = document.getElementById ('+ + txtLastEditBy.ClientID +'); "+" lblLastEditBy.value = Edited; "+" var lblDateCreated = document.getElementById ('+ + txtTallyBoardEntryDate.ClientID +' ''); "+" LblDateCreated.value = dateCreated; "+" Fully Booked = Document. GetElementById ( '"+ ChkFullyBooked.ClientID +' ');" + "fully booked. Original = fully ;; +"} "+" & lt; / script & gt; ");%>  

Later in my code, an excerpt:

  ...  & Lt; / Tr & gt; & Lt; Tr & gt; & Lt; Td colspan = "2" style = "text-align: left" & gt; ASP: checkbox runat = "server" id = "chkFullyBooked" text = "fully booked?" Checked = "false" /> gt; & Lt; / Td> & Lt; / Tr & gt; Edit: Definitely this means that I can not access ClientID as an empty reference exception on the above code. 

Edit: As a dirty fix, I had response.redirect (request.url.tostring) instead of leaving the postback on the button, and for some godforsaken reasons it works fine .. < /p>

Since you have the "hard coding" value for the text / checkbox via javascript on the runtime, None of these values ​​have any knowledge and so they will remain empty after the latest or postback.

You will see that Response.Redirect maintains your values ​​because when that server-based method is called, it goes through all the form fields and collects their values ​​to store in the viewstate. And when they come back from the server request, then they recapitalize them.

Did you try to load initial values ​​through the Page_load function for the first time on the user page? This ensures that values ​​will be stored in the viewstock while executing your actions based on modal popup actions.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -