About Msg/Alert Boxes in a Web Application

  • Thread starter Thread starter Coleen
  • Start date Start date
C

Coleen

Please see threads on "Dumb question about Message boxes" - I went to the
specified link - this works great if all you want to do is display a message
box before any of your script behind the aspx.vb runs or on the click event,
but if you are actually trying to validate user selections, such as when an
item from a drop-down is selected, I get an error if I put it in this code:

<asp:dropdownlist id="ddl_year" runat="server" Width="40%"
CssClass="datagrid " AutoPostBack="True" OnSelectedIndexChanged="script
language="VBScript"> MsgBox "Hello there" </script>"></asp:dropdownlist>

I get the red-squiggly on ="VBScript" and "Hello There" and of course a
build error when I try to run it. What I really need to do is validate a
selection from the dropdown list box (a date), if it is not the current
date, then I need a msg or alert box to warn the user that their selection
is not current and that the data they will be viewing is not updateable.
Where do I need to put this code to get it to run after a selection has been
made? Any suggestions? Thanks

Coleen
 
Why not use a custom validator control for this? This allows you to write
your own client-side JavaScript (so you can include the native alert()).
And in the corresponding server-side validation, you can push a client-side
script down to the client if need be.
 
The whole point is that I don't know JavaScript!!! I was/am searching for
an alternative to writing JavaScript code to do the validation. The link
that Michael Lang gave looks great, but when I use it in my .aspx code for
the drop down, I get errors. Any suggestions?
 
Yes, my suggestion is the same as before. I'm sorry that you don't want to
use JavaScript, but JavaScript is the only client-side scripting language
that is supported by all mainstream browsers. For this reason, JavaScript
is the defacto client-side scripting standard.

You asked how to accomplish your goal and this is how it is done.
 
It's not that I don't want to use it...it's that I don't know JavaScript.
This means a learning period, which I was hoping to avoid, since we need to
keep this project on schedule. But, alas, if I have to learn JavaScript, I
have to; I guess it will look good in a resume down the line...Thanks for
your help.
 
Back
Top