473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Javascript messagebox

This program in asp.net 2.0 is a Spanish/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 Spanish and one English. When a user enters a Spanish 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.

************************************************** ***
Expand|Select|Wrap|Line Numbers
  1. Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
  2.         If e.Item.ItemType = ListItemType.Item Or _
  3.      e.Item.ItemType = ListItemType.AlternatingItem Then
  4.             Dim ds As SqlDataSource
  5.             ds = CType(e.Item.FindControl("Spanish"), _
  6.             SqlDataSource)
  7.             Dim Words() As String
  8.             Dim arySpanish() As String
  9.             Dim strSpanish As String
  10.             Dim i As Integer
  11.             Dim strScript As String = DataBinder.Eval(e.Item.DataItem, _
  12.                 "English").ToString()
  13.  
  14. ‘The below 7 lines is where I am trying to get the js messagebox but it is not working
  15.             TextBox1.Text = strScript
  16.             If TextBox1.Text <> strScript Then
  17.                 ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", "alert ('wrong')", True)
  18.                 Dim streng As String = "<script language='JavaScript'> alert('wrong') </script>"
  19.             End If
  20.  
  21.             strSpanish = DataBinder.Eval(e.Item.DataItem, _
  22.     "spanish").ToString()
  23.             Words = strSpanish.Split("-")
  24.             arySpanish = strSpanish.Split("-")
  25.             strSpanish = ""
  26.             For i = 0 To UBound(arySpanish)
  27.                 strSpanish = strSpanish & arySpanish(i) & Environment.NewLine
  28.                 TextBox2.Text = strSpanish
  29.             Next
  30.             End If
  31.     End Sub
  32.  
*************************************
Jul 27 '10 #1
2 3546
jhardman
3,406 Expert 2GB
posted in the Classic ASP forum on accident. I will move it to the ASP.NET forum.

Jared
Jul 29 '10 #2
Frinavale
9,735 Expert Mod 8TB
I think that I would probably include the JavaScript into the page (in the <head> section of the page) so that you can call it on the JavaScript's window onload event. Have the JavaScript function check a HiddenField on the page to determine whether or not the message should be displayed....set the HiddenField in your C# or VB.NET server-side code.

-Frinny
Jul 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Kim Forbes | last post by:
Hello all, I have simple function that I call from an alert box alert(testScore); It works fine. Unfortunately, I do not like the sound and Exclamation point icon that appears. I'd like a...
5
by: John | last post by:
Hi all, Is it possible to create a Javascript messagebox that shows the buttons Yes and No instead of normal confirm? Regards John.
5
by: Curt Emich | last post by:
I always thought writing a simple diagnostic message in a message box would be pretty simple. Not in .NET. First, I wrote this amazingly complex piece of code: MessageBox.Show("yer mama") ...
10
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
13
by: Chris | last post by:
I can create Javascript confirm message boxes during page creation, etc adding them to the button attributes (many good posts on this!). But how can I add this event after the button is pressed? I...
1
by: Mike Fellows | last post by:
ive read a few tutorials, but i cant get my head round it, all i need is a messagebox that displays "update" "new" on update i want it to update a record, on new i want it to create a new record...
3
by: VMI | last post by:
I know this isn't the best group to post aspnet question, but the MS asp.net NG hasn't been very helpful lately. I've been trying to add a messagebox following the examples I've seen on the web,...
4
by: Michael Duclon | last post by:
Does anyone know how I might use the webclient class to navigate to a web page in a vb.net app, and then if a JavaScript popup appears from the web page I go to, read the message in it or content...
2
by: pageload | last post by:
What is the length of Javascript message box
1
by: kret | last post by:
Hi, this is my first post so first of all I would like to say hello :) Now getting to my problem. In my job I have to create an ActiveX control in .NET 1.1 that can be lunched from IE....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.