I’m still learning about postbacks etc, but I can’t work out why I have to click the following requires me to click the ‘Submit’ button twice. It simply needs to populate the textbox with the querystring text for editing. If you don’t edit anything and click submit, it redirects to kitchen.aspx as required, but if you click into the textbox and edit the text, then click submit, you need to click submit again.
<asp:TextBox ID="txtNote" runat="server" AutoPostBack="True" visible="true" TextMode="MultiLine" Columns="40" rows="5" ></asp:TextBox>
<asp:ImageButton ID="imgSubmitMessage" alt="Submit" runat="server" width="40%" OnClick="SubmitMessage_Click" ImageUrl="~/files/images/icons/sendMsgToCustomerButton.gif" />
VB.Net…
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If (Not IsPostBack) Then
txtNote.text=Request.QueryString("note")
End If
End Sub
Protected Sub Submit_Click(sender As Object, e As System.EventArgs)
Dim DBConnect As New DBConn
Using db As DbConnection = DBConnect.Conn("DBConnectionString")
Dim cmd As SqlCommand = DBConnect.Command(db, "updateNote")
cmd.Parameters.Add(New SqlParameter("orderID", SqlDbType.UniqueIdentifier, ParameterDirection.Input)).Value = Guid.Parse(Request.QueryString("orderID"))
cmd.Parameters.Add(New SqlParameter("note", SqlDbType.VarChar, 1020, ParameterDirection.Input)).Value = txtNote.text
db.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
cmd = Nothing
db.Dispose()
db.Close()
End Using
response.redirect("kitchen.aspx"))
End Sub