Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET - Controls submit wrong information
    text
    copied!<p>in ASP.NET I have 2 text boxes, one dropdownlist and a button that submit the wrong information to a method that I am calling.</p> <p>I am using Linq to SQL with Entity Framework.</p> <p>What I am trying to do is updating a ticket in the database that contains a subject, content and isPublic(bool). When I load the page it automatically fills the text boxes and combo boxes with the fields from ticket where the ticket id is known. So if ticket 2 is clicked,the page loads and the controls get filled with the information from that ticket. So if ticket 2 has a subject Dogs, content a Dog is an animal and isPublic is true, you'll get to see that information in those boxes. Now, when I change the content of those controls and press the button, it loads a method that I wrote to update the database:</p> <pre><code> public void updateTicket(int _ticket_id,bool _isManager,string _subject,bool _isPublic,string _description) { TICKET ticket = (from t in db.TICKETs where t.id == _ticket_id select t).First(); REACTION reaction = (from i in db.REACTIONs where i.tickets_id == _ticket_id select i).FirstOrDefault(); ticket.subject = _subject; ticket.isPublic = _isPublic; reaction.contents = _description; db.SubmitChanges(); } </code></pre> <p>And I call this function like this:</p> <pre><code>instanceOfTickets.updateTicket(2, false, TextBox1.Text,waarde,TextBox2.Text); </code></pre> <p>Where ticket_id is 2 just for testing and waarde is Public. The problem that I have is when I debug this method, the controls return the wrong information to the method overload. Instead for example cat, it still sends dog to my method. Even though I really filled in cat before clicking the button.</p> <p>Does anyone know why it does this and how to fix this? Thanks in advance.</p> <p><strong>EDIT:</strong></p> <p>To be more clear:</p> <p>After loading the page:</p> <p><img src="https://i.stack.imgur.com/ISJjY.png" alt="enter image description here"></p> <p>Here I changed the content:</p> <p><img src="https://i.stack.imgur.com/aEnOv.png" alt="enter image description here"></p> <p>After I pressed the button and started to debug:</p> <p><img src="https://i.stack.imgur.com/bcX2I.png" alt="enter image description here"></p> <p><strong>EDIT 2:</strong></p> <p>So I figured out what causes the problem but I don't know how to fix it. I have a var ticket that contains the ticket after I used a linq query to get that ticket from the database. When I tell a text box to get fill itself with the subject (or content) from that ticket, it keeps somehow "connected" to that. So when I say textbox1.text = ticket.subject , the subject will show up in that text box but it will always stay like that. How do I "overwrite" that so that I can send the proper information to my method?</p>
 

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