?
Solved

alert/msgbox in validator using vb.net

Posted on 2003-03-27
8
Medium Priority
?
593 Views
Last Modified: 2006-11-17
hi all,

i have several validators (for ex:RequiredFieldValidator, RegularExpressionValidator, etc) to check user input. the problem is, it has ErrorMessage property that WRITES the warning on the screen instead of popping it up like what usual alert/msgbox does. i don't want a written message, i want an alert/msgbox!!!! =( =(
i've read that it's not possible to do it in asp.net since it's server-side scripting, and i've been suggested to do it in javascript.

however, can anybody help me doing it in vb & asp .net? thx a bunch!
0
Comment
Question by:lalok
[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
  • 4
  • 3
8 Comments
 
LVL 28

Expert Comment

by:iboutchkine
ID: 8217494
If not your validation criteria then

If (Not Me.IsStartupScriptRegistered("Startup")) Then
     Me.RegisterStartupScript("TestMsg",  _
          "<script language='javascript'>alert('Test message...');</script>")
End If


End if
0
 

Author Comment

by:lalok
ID: 8217586
to iboutchkine>>
How to write the validation criteria? *i'm sorry, my knowledge of JavaScript is not that good*

here's how i do the validation for date format
===========================================================

<asp:RegularExpressionValidator Id="revDate" ControlToValidate="txtDate" ErrorMessage="Wrong Date Format!" ValidationExpression="^(((0[13578]|10|12)([-./])(0[1-9]|[12][0-9]|3[01])([-./])(\d{4}))|((0[469]|11)([-./])([0][1-9]|[12][0-9]|30)([-./])(\d{4}))|((02)([-./])(0[1-9]|1[0-9]|2[0-8])([-./])(\d{4}))|((02)(\.|-|\/)(29)([-./])([02468][048]00))|((02)([-./])(29)([-./])([13579][26]00))|((02)([-./])(29)([-./])([0-9][0-9][0][48]))|((02)([-./])(29)([-./])([0-9][0-9][2468][048]))|((02)([-./])(29)([-./])([0-9][0-9][13579][26])))$" Display="Dynamic" RunAt="Server" />

===========================================================

Here, validation criteria is written in "ValidationExpression" and "ErrorMessage" will write the message on the screen if "ValidationExpression" is violated.
What I want to do is: how to show an alert/msgbox showing the message instead of having it written on the screen?
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 8217632
Is not it  easier to put it under some event (button click ot other)

If not IsDate(myDate) then
If (Not Me.IsStartupScriptRegistered("Startup")) Then
    Me.RegisterStartupScript("TestMsg",  _
         "<script language='javascript'>alert('Test message...');</script>")
End If
End if
0
Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

 

Author Comment

by:lalok
ID: 8339466
what kind of validation IsDate() method use? i have to validate it based on dd-mm-yyyy (16-04-2003) expression.
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 8340294
IsDate checks for valid date depending on the regioanl setting on your PC. In my case it is MM/dd/yyyy
0
 

Author Comment

by:lalok
ID: 8340310
i've put lcid=2057 (british) for dataformatstring so that date will be treated as dd-mm-yyyy though what i need is dutch dataformatstring.
is it enough?

i don't know my pc's regional setting *can't think due to brain freeze*
0
 

Accepted Solution

by:
lalok earned 0 total points
ID: 8530894
announcement:
It's been a while since I made this thread and I've already solved the problem by myself. I'm using validation summary instead of javascript.

This is how I do it:
<asp:ValidationSummary RunAt="Server" ShowSummary="False" ShowMessageBox="True"/>
Also, I've assigned CausesValidation = True to my button/linkbutton so that whenever a user forgets to fill at least 1 webcontrol, a messagebox will appear.

Thus, I'd like to announce that I'm going to ask admin to lock my question.

to jboutchkine: thx very much for your help.
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 8574986
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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