I.T. Discussion Community!
-Collapse +Expand
ASP Classic
Search ASP Classic Group:

Advanced
-Collapse +Expand ASP Classic Store

Prestwood eMagazine

November Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyASP Classic Coding BoardASP Classic - Handling Data Topic   Print This     

Diplaying javascript error message from DB

Diplaying javascript error message from DB in ASP Classic - Handling Data topic (part of our ASP Classic Coding group).

Quick Search: Diplaying   javascript   message   Diplaying javascript   Diplaying javascript error   message DB  
khatib_b
-- UNK

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

*************************************************************************

 Posted 9 years ago (Thread Starter)
Comment Quote
About khatib_b -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #14261, 1 replies
Thread Started 8/7/2010 2:18:23 PM
View Counter=5084
Last Reply Posted 9/20/2010 9:47:53 AM)
Location=-- UNK 
Joined=11 years ago   MB Posts=4  
Most Recent Post
dmichael
Tupelo, MS

My comment below will look like this.  8^D

 

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

How about changing the IF statement to an IF that looks at the length of strScript.  If > 0, you found a match.  Otherwise...

            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

 Posted 9 years ago
Comment Quote
About dmichael -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #14295 (Level 1.1)  Reply to 14261
Thread Started 9/20/2010 9:43:29 AM
Location=Tupelo, MS  
Joined=18 years ago   MB Posts=18  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1193A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #14261 Counter
5084
Since 8/7/2010

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech