Solved

How do I prompt messages to a user in ASP?

Posted on 2008-06-10
13
587 Views
Last Modified: 2012-05-05
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
Comment
Question by:ipjyo
[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
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21753865
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
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 21754940
With ASP classic you can use client-side scripting - vbscript (MsgBox) or javascript (alert) to do so.
0
 

Author Comment

by:ipjyo
ID: 21755150
I am using classic ASP only.
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 14

Expert Comment

by:_Stilgar_
ID: 21755188
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
 

Author Comment

by:ipjyo
ID: 21756682
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
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21757309
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
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21757314
0
 
LVL 22

Expert Comment

by:neeraj523
ID: 21758769
try this
<%
errMsg = "Error msg from Stored Procedure"
%>
<TEXTAREA rows=2 cols=20 id=textarea1 name=textarea1>
<%=errMsg%>
</TEXTAREA>
0
 

Author Comment

by:ipjyo
ID: 21759301
How do I enable the text area only when an error occurs?
any idea please?

thanks
0
 
LVL 22

Accepted Solution

by:
neeraj523 earned 500 total points
ID: 21759394
<%
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
 

Author Comment

by:ipjyo
ID: 21759403
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
 

Author Comment

by:ipjyo
ID: 21759442
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
 
LVL 22

Expert Comment

by:neeraj523
ID: 21759632
Not clear..
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

726 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