Solved

client side validation

Posted on 2004-09-06
5
236 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now