Hi,
I have a submit button that saves record successfully.
The problem i have with it is that it can only show ModalPopupExtender after the first save(first click of the submit button).On the second click of the submit button it doesn't show ModalPopupExtender even though record is saved.How do i go about it.
Here is my markup:
<asp:UpdatePanel runat="server" ID="upMain" UpdateMode="Conditional" ChildrenAsTriggers ="true" >
<ContentTemplate>
<asp:LinkButton ID="lbtn" runat="server" >LinkButton</asp:LinkButton>
<ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID ="lbtn"
PopupControlID ="pnlPopup" OkControlID ="btnOks" BackgroundCssClass="modalBackground"></ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display:none ">
<div class="header">
Confirmation </div><div class="body">
<asp:ImageButton ID="tick_img" runat="server" Enabled ="false" ImageUrl="~/images/tick_round_btn.jpg" />
Record saved successfully!! </div><div class="footer" align="right">
<asp:Button ID="btnOKs" runat="server" Text="OK" CausesValidation ="false" />
</div>
</asp:Panel>
</ContentTemplate>
<Triggers >
<asp:AsyncPostBackTrigger ControlID ="btnSubmit" EventName ="Click" />
<asp:AsyncPostBackTrigger ControlID ="lbtn" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:ImageButton ID="btnSubmit" runat="server" ImageUrl="~/images/save_32.png" OnClick ="btnSubmit_Click" />
<asp:ImageButton ID="Cancel" runat="server" ImageUrl="~/images/close_new.png" />
Code Behind
Protected Sub btnSubmit_Click(sender As Object, e As ImageClickEventArgs)
Dim constr As String = ConfigurationManager.ConnectionStrings("SY_InventoryConnectionString").ToString()
Using con As New SqlConnection(constr)
con.Open()
Using cmd As New SqlCommand("InsertSupplier", con)
cmd.Parameters.Add("@SupplierName", SqlDbType.VarChar).Value = txtsupplier.Text.Trim()
cmd.Parameters.AddWithValue("@Address", Me.txtaddress.Text.Trim())
cmd.Parameters.AddWithValue("@ContactNo", Me.txtmobile.Text.Trim())
cmd.Parameters.AddWithValue("@Fax", Me.txtfax.Text.Trim())
cmd.Parameters.AddWithValue("@ContactPerson", Me.txt_contactperson.Text.Trim())
cmd.Parameters.AddWithValue("@Email", Me.txtemail.Text.Trim())
cmd.Parameters.Add("@PayTerm", SqlDbType.VarChar).Value = drpPayTerm.SelectedItem.Value
cmd.Parameters.Add("@PayMethod", SqlDbType.VarChar).Value = drpPayMethod.SelectedItem.Value
cmd.Parameters.Add("@TaxDesc", SqlDbType.VarChar).Value = drpTaxScheme.SelectedItem.Value
cmd.Parameters.AddWithValue("@Phone", Me.txtphone.Text.Trim())
cmd.Parameters.AddWithValue("@Website", Me.txtwebsite.Text.Trim())
cmd.CommandType = CommandType.StoredProcedure
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
txtsupplier.Text = String.Empty
txtaddress.Text = String.Empty
txtmobile.Text = String.Empty
txtfax.Text = String.Empty
txt_contactperson.Text = String.Empty
txtemail.Text = String.Empty
drpPayTerm.ClearSelection()
drpPayMethod.ClearSelection()
drpTaxScheme.ClearSelection()
txtphone.Text = String.Empty
txtwebsite.Text = String.Empty
mpe.Show()
End Sub