This program in asp.net 2.0. It is a Hebrew/English Dictionary.
It consists of two textboxes,one button and a datalist. The datalist is bound to an acces database consisting of two columns; One Hebrew and one English. When a user enters a Hebrew word in textbox1 and clicks the button, the meaning of the word appears in textbox2. Now sometimes a user enters a word that is not in the database. I want, in this case, to have a javascript messagebox to popup saying Either the word is not listed or misspelled.
I tried several javascripts to popup in code behind but that did not work. I know that a clientside should be included but I am not able to do that.
The sub below is the one I am using to fetch the words and it is working perfect as long as I enter a word that is already in access database. The words in the rows in database are separated by hyphens so I am using a Split fuction which is also working perfectly.
*************************************************************************
Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
Dim ds As SqlDataSource
ds = CType(e.Item.FindControl("Hebrew"), _
SqlDataSource)
Dim Words() As String
Dim aryHebrew() As String
Dim strHebrew As String
Dim i As Integer
Dim strScript As String = DataBinder.Eval(e.Item.DataItem, _
"English").ToString()
The below 7 lines is where I am trying to get the js messagebox but it is not working
TextBox1.Text = strScript
If TextBox1.Text <> strScript Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", "alert ('wrong')", True)
Dim streng As String = "<script language='JavaScript'> alert('wrong') </script>"
End If
strHebrew = DataBinder.Eval(e.Item.DataItem, _
"Hebrew").ToString()
Words = strHebrew.Split("-")
aryHebrew = strHebrew.Split("-")
strHebrew = ""
For i = 0 To UBound(aryHebrew)
strHebrew = strHebrew & aryHebrew(i) & Environment.NewLine
TextBox2.Text = strHebrew
Next
End If
End Sub
*************************************************************************