Solved

client side validation

Posted on 2004-09-06
5
240 Views
Last Modified: 2010-04-23

Hi
 
      I have a dropdown list on the form and have to validate it using client side validation. If the user does not select any value from dropdown list, error message should pop up. can anybody give code for this validation using javascript in vb.net

thanks

sandeep
0
Comment
Question by:sandeep437
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 10

Expert Comment

by:jnhorst
ID: 11992796
This should be on the ASP.NET forum, but I'll help out here:

If you have a button or something that is clicked to post the page back to the server, have it check the dropdown list like this: (ddl is the name I'll use for the list).

if (ddl.SelectedIndex == 0)
{
     // the following is basic javascript to show a message.
     string jsMsg = "<script language=\"javascript\">alert('You need to make a selection...');</script>"
     Response.Write(jsMsg);
}
else
{
     // do whatever with the drop down selection.
}

The alert() function in javascript is the browser equivalent of MsgBox().

John

John
0
 

Author Comment

by:sandeep437
ID: 11993420
Hi john

    i am looking for code in vb.net  not  c#.net.
i declared a string like this.

dim jsMsg as String  = "<script language=\"javascript\">alert('You need to make a selection...');</script>"
Response.write(jsMsg)

but its showing error as "end of statement expected".

do you know where its going wrong.

thanks

sandeep
0
 
LVL 10

Accepted Solution

by:
jnhorst earned 50 total points
ID: 11993874
The escape sequence of \" will not work in VB.NET (it is a C# thing, sorry about that).  Do this:

dim jsMsg as String  = "<script language='javascript'>alert('You need to make a selection...');</script>"
Response.write(jsMsg)

John
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Add Combobox column to datagridview using vb.net 2 42
Run software updates from the website 6 49
Updating Printer Details in VB.Net 16 42
Subtract dates in vb.net 6 33
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question