473,789 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript messagebox

7 New Member
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 3576
jhardman
3,406 Recognized Expert Specialist
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 Recognized Expert Moderator Expert
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....se t 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
21490
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 nice message box like VBA message box #64 to appear. I know hardly anything at all about VB or VBA. But, I do know you can call a VB function from Javascript. How? Is it
5
120495
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
1559
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") It wouldn't even complile. "Gee...", I mused. "Maybe there's no reference to that method in my project". I muzed correctly. So I added a reference to System.Windows.Forms, which is where our beloved "MessageBox" method
10
2354
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 like it could help, both in the VS help and in this NG. I found lots of examples of people saying how easy it is and showing examples, and examples in the help. But I have two problems: 1. All the examples show all the code in HTML, usually...
13
5679
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 have created an Is_Dirty routine checking for field changes on my page then if the user clicks on the "exit" button I check for Is_Dirty = true and want to ask then "do you want to exit without saving?". It's a code behind where if the value of...
1
1311
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 how do a) create the messagebox then b) interprate the click i understand i need to do this in javascript, all the tutorials ive read are
3
6499
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, but with no luck. I have an aspx page where the user enters a bunch of data and clicks 'Submit'. When the user clicks on the 'Submit', I want to run an SP that returns true/false depending on the data. If false, then my MessageBox will pop up...
4
2696
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 of it, then close it so I can continue on. I don't know how to reference the popup box or send a command to click the ok button to close it. Mike Duclon
2
2320
by: pageload | last post by:
What is the length of Javascript message box
1
8301
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. This part is done but next requirement is that after closing ActiveX I have to redirect parent page to location X or Y depending on how the
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.