• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 595
  • Last Modified:

How do I prompt messages to a user in ASP?

Is there anything I can use to prompt some messages to the user?
suppose if the form has to display some message if the user clicks a submit button without selecting a listbox values.

thanks
0
ipjyo
Asked:
ipjyo
  • 5
  • 3
  • 2
  • +2
1 Solution
 
naspinskiCommented:
Are you using asp.net?

Of so, you can use the built int validators:
<asp:TextBox ID="txt" runat="server" />
<asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="txt" ErrorMessage="required" />
<!--makes sure that txt has something in it, otherwise the form won't submit-->

Open in new window

0
 
_Stilgar_Commented:
With ASP classic you can use client-side scripting - vbscript (MsgBox) or javascript (alert) to do so.
0
 
ipjyoAuthor Commented:
I am using classic ASP only.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
_Stilgar_Commented:
Well, then either wire your onSubmit event of your form, or have the submit button call a js function for validation, and if it finds a need to get the user's attention, it should call alert('message'); and return false;
0
 
ipjyoAuthor Commented:
Actually I hava to call a stored procedure and then print the error message in a text area.
I tried to define a text area and made it disabled on page load.
Then I need to retreive the return value from the stored procedure and print the message accordingly.
So basically I want to print a message using something like response.write I guess.
can I use something like
<TEXTAREA rows=2 cols=20 id=textarea1 name=textarea1>
</TEXTAREA>
<%
Request.Form("textarea1").Item = "error message"
Response.Write(Request.Form("textarea1").Item)
%>

Thanks for your help

0
 
Loganathan NatarajanLAMP DeveloperCommented:
try this,

<%'this code would run on server
strMsg = "Type your message here.."
%>
<script language="vbscript">
'this code would run on client
msgbox "<%=strMsg%>"
</script>

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
0
 
neeraj523Commented:
try this
<%
errMsg = "Error msg from Stored Procedure"
%>
<TEXTAREA rows=2 cols=20 id=textarea1 name=textarea1>
<%=errMsg%>
</TEXTAREA>
0
 
ipjyoAuthor Commented:
How do I enable the text area only when an error occurs?
any idea please?

thanks
0
 
neeraj523Commented:
<%
errMsg = "Error msg from Stored Procedure"
if errMsg <> "" Then
   styleStr = "VISIBLE"
Else
   styleStr = "HIDDEN"
End if
%>
<TEXTAREA rows=2 cols=20 id=textarea1 name=textarea1 style="VISIBILITY:<%=styleStr%>">
<%=errMsg%>
</TEXTAREA>
0
 
ipjyoAuthor Commented:
when i try the following
<%
errMsg = "Error msg from Stored Procedure"
%>
<TEXTAREA rows=2 cols=20 id=textarea1 name=textarea1>
<%=errMsg%>
</TEXTAREA>

It is printing "0" in the text area
0
 
ipjyoAuthor Commented:
actually when I declared the errMsg in a sub method, it is giving "0"
If I try to declare errMsg in <%  %>
it is giving the actual message.
But I need to capture the error code in a method.
How can I modify this?

thanks
0
 
neeraj523Commented:
Not clear..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now