Stop modalpopup closing on postback




Stop modalpopup closing on postback
By defauly a modalpopup automatically closes/hides on postback a simple solution to this is to simply set your postback even to show that modalpopup again by using the below code:
  1. PanelID.Show()  
An example of this in use would be:
  1. Protected Sub btnAccessLogin_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnAccessLogin.Click   
  2.         Dim MyConnection As SqlConnection   
  3.         MyConnection = New SqlConnection()   
  4.         MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString   
  5.   
  6.         Dim strCode As String = txtAccessCode.Text.ToLower   
  7.         Dim sql As String = "SELECT * FROM CODES WHERE code = '" + strCode + "'"  
  8.   
  9.         Dim resultsDataSet As New DataSet()   
  10.         Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(sql, MyConnection)   
  11.         myDataAdapter.Fill(resultsDataSet, "codes")   
  12.            
  13.         If resultsDataSet.Tables("codes").Rows.Count = 0 Then  
  14.             lblAccessCode.Text = "Invalid access code, please try again:"  
  15.             lblAccessCode.ForeColor = Drawing.Color.Red   
  16.             PanelID.Show()   
  17.         Else  
  18.             lblAccessCode.Text = "The correct code was entered."  
  19.         End If  
  20. End Sub  


No one has said that they like article yet, be the first and click here (0)
Send a link to this page via email Send a link to this page