By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,223 Members | 1,371 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,223 IT Pros & Developers. It's quick & easy.

javascript validation

P: n/a
I have a method that I use for Javascript validation (see below). What
I want to do is change the alert title, buttons, icon etc. Does anybody
know the correct syntax to do this?

private void Gen_Alert(string Key, string msg)
{
string str = "";
str += "<script language='javascript'>";
str += "alert('"+msg+"')";
str += "</script>";
RegisterStartupScript(Key, str);
}
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Dec 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You can't. There are several pre-defined functions in JavaScript that do
similar things. The alert() function simply pops up a MessageBox with an OK
button on it. The confirm() function pops up a MessageBox with an OK and
Cancel button, and returns true if OK is clicked, and false if Cancel is
clicked. The propmt() function pops up a MessageBox with a text box and an
OK button, and returns the string entered into the text box.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mike P" <mi*******@gmail.com> wrote in message
news:uf**************@TK2MSFTNGP14.phx.gbl...
I have a method that I use for Javascript validation (see below). What
I want to do is change the alert title, buttons, icon etc. Does anybody
know the correct syntax to do this?

private void Gen_Alert(string Key, string msg)
{
string str = "";
str += "<script language='javascript'>";
str += "alert('"+msg+"')";
str += "</script>";
RegisterStartupScript(Key, str);
}
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***

Dec 13 '05 #2

P: n/a
Kevin,

Thanks for the info about confirm() and prompt(), they may come in
useful!
Cheers,

Mike
*** Sent via Developersdex http://www.developersdex.com ***
Dec 13 '05 #3

P: n/a
You're quite welcome, Mike. I probably should have mentioned another, more
difficult alternative, which is to design a popup that does whatever you
need. It is more difficult because, for example, many browsers don't allow
popups. This can be overcome, however, by the use of an
absolutely-positioned div with a zIndex higher than the rest of the page.
Making it look like a dialog box is somewhat problematic, and unlike a
regular popup, its position is nailed to the position of the window below
it. It also requires a good bit of DHTML (JavaScript/HTML/CSS) programming
to use it, but if you design it well, it can be re-used in the same (and
other) web applications. The greatest difficulty with this sort of solution
is making it look and behave more or less the same in all browsers. But it
can certainly be done.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Mike P" <mi*******@gmail.com> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
Kevin,

Thanks for the info about confirm() and prompt(), they may come in
useful!
Cheers,

Mike
*** Sent via Developersdex http://www.developersdex.com ***

Dec 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.