Hi there,
I have a button that when clicked fires an Insert command. in the past I kept putting blank records into the database so what I thought is to put a validator in.
What happens now is i click the button, it tells me the textbox is required... i put something i click button it says updated... and then when i go to click a button that hides the current panel and opens a new one it won't let me.... says required. in the status bar it has a javascript message. I dont i am doing it right...
Button
--------
Code:
Private Sub btnAddNews_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNews.Click
If IsValid Then
'Convert the article so that it can be into the database.
Dim ArticleText As String = MyCstr(txtNewsArticle.Text, True, True)
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Inetpub\wwwroot\davejenkinscouk\davesdatabase.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
dbConnection.Open()
Dim strSQL As String = "INSERT INTO tbl_News(NewsTitle, NewsArticle, NewsImage, NewsLink, NewsComments) values('" & _
txtNewsTitle.Text & "','" & _
ArticleText & "','" & _
txtNewsImage.Text & "','" & _
txtNewsLinks.Text & "','" & _
chkComments.Checked & "')"
Dim myCommand As New OleDb.OleDbCommand(strSQL, dbConnection)
myCommand.ExecuteNonQuery()
dbConnection.Close()
'Rebind the datagrid
dgNewsArticles.DataSource() = getNewsArticles()
dgNewsArticles.DataBind()
'If it inserts correctly then the following is displayed.....
showNewsMessage.Visible = "True"
showNewsMessage.Text = "record added successfully."
'Clear the field values.
txtNewsTitle.Text = ""
txtNewsArticle.Text = ""
txtNewsImage.Text = ""
txtNewsLinks.Text = ""
chkComments.Checked = "False"
End If
End Sub
with a normal validator there checking the txtNewsTitle.Text box..
cheers
David Jenkins
-------------------------------------------------------------
Do you want to make extra money around your commitments?
Credit cards, bills, loans and a mortgage - all getting you down?
Is your pension going to be enough when you retire?
There is a solution visit
http://www.1stmillion.co.uk
or call 01772 489521