Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit 3:</strong> </p> <p>The below code will work for static controls, but dynamically-created controls will not be preserved on postback. You will need to store the updated values so they can be retrieved on postback somehow (e.g. a Session variable or HiddenField). If possible, I would create the controls statically and populate them in <code>page_load</code>, hiding controls with no data - this would allow you to get the values on postback as below.</p> <hr> <p>Hmm...I set up a super simplified version of your code and ran it pretty much as is (without the database function), and it seems to be working fine. </p> <p>Here is the simplified version I used:</p> <pre><code>&lt;asp:Content id="Content1" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;asp:ImageButton ID="imgbtnSave" runat="server"&gt;&lt;/asp:ImageButton&gt; &lt;asp:PlaceHolder ID="PlanPlaceHolder" runat="server"&gt; &lt;asp:TextBox runat="server" ID="txtTrainingStart" value="before" &gt;&lt;/asp:TextBox&gt; &lt;/asp:PlaceHolder&gt; &lt;/asp:Content&gt; </code></pre> <p>Javascript:</p> <pre class="lang-js prettyprint-override"><code>function txtTrainingStart_Click(txtTrainingStart, txtTask) { var currentdate = new Date(); var test = "after"; txtTrainingStart.value = test; txtTrainingStart.style.backgroundColor = "yellow"; } </code></pre> <p>VB: </p> <pre><code>Protected Sub imgbtnSave_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs Handles imgbtnSave.Click For Each item As TextBox In PlanPlaceHolder.Controls 'need updated textbox values here.' Debug.WriteLine(item.ID) Debug.WriteLine(item.Text) Next End Sub </code></pre> <p>I'm getting the updated value of the textbox, so you should be able to pass that value to a function and do whatever operations you need.</p> <p>Let me know if I'm missing something.</p> <p><strong>Edit 2:</strong> I just had a thought--can you check if <code>page_load</code> is being called after you click the save button? I wonder if it is overwriting your updated values with the original values again.</p> <p>If it is, I would wrap the database functionality in <code>page_load</code> with a postback check:</p> <pre><code>If Not IsPostBack ' connect to database' ' populate placeholder' End If </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload