473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to use a messagebox in asp.net

Hi,

I made a small ASP.net web page and in it I used a messagebox to confirm
first before an execution would take place.
It worked fine while testing it locally, but when i published it on a server
it didn't work anymore.

I understand why, but still have the problem that I would like the user to
confirm first before execution begins.

How is it done?
I searched a bit and found javascript solution but how do I fit them in my
code?

My code looks something like this :
Dim somethings
result = MsgBox(MsgText.ToString, MsgBoxStyle.YesNo +
MsgBoxStyle.MsgBoxSetForeground, "title")

If result = vbYes Then
start execution
Else
some code
End If

--
regards,

Arvid
Mar 22 '07 #1
28 3332
What do you have behind the MsgBox?
Are you using Javascript in another routine?
There is no ASP.Net intrinsic control like this - however there is a
ConfirmButton in the Ajax toolkit.

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
Hi,

I made a small ASP.net web page and in it I used a messagebox to confirm
first before an execution would take place.
It worked fine while testing it locally, but when i published it on a
server
it didn't work anymore.

I understand why, but still have the problem that I would like the user to
confirm first before execution begins.

How is it done?
I searched a bit and found javascript solution but how do I fit them in my
code?

My code looks something like this :
Dim somethings
result = MsgBox(MsgText.ToString, MsgBoxStyle.YesNo +
MsgBoxStyle.MsgBoxSetForeground, "title")

If result = vbYes Then
start execution
Else
some code
End If

--
regards,

Arvid

Mar 22 '07 #2
This can help you:

http://usableasp.net/DeveloperPage.a...rAndClient.htm

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
Hi,

I made a small ASP.net web page and in it I used a messagebox to confirm
first before an execution would take place.
It worked fine while testing it locally, but when i published it on a
server
it didn't work anymore.

I understand why, but still have the problem that I would like the user to
confirm first before execution begins.

How is it done?
I searched a bit and found javascript solution but how do I fit them in my
code?

My code looks something like this :
Dim somethings
result = MsgBox(MsgText.ToString, MsgBoxStyle.YesNo +
MsgBoxStyle.MsgBoxSetForeground, "title")

If result = vbYes Then
start execution
Else
some code
End If

--
regards,

Arvid

Mar 22 '07 #3
How is it done?

You don't. If you want user interaction it has to be done via javascript on
the client, not server-side code. If you use message boxes in asp.net code
the box appears on the server and no-one is there to click it, certainly not
the intented client.
Mar 22 '07 #4
You could create a routine that creates the Javascript behind the scenes -
and use it dynamically whenever and wherever you'd like.
Check out this tip from ASPNet101.com:
http://aspnet101.com/aspnet101/tips.aspx?id=203

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
Hi,

I made a small ASP.net web page and in it I used a messagebox to confirm
first before an execution would take place.
It worked fine while testing it locally, but when i published it on a
server
it didn't work anymore.

I understand why, but still have the problem that I would like the user to
confirm first before execution begins.

How is it done?
I searched a bit and found javascript solution but how do I fit them in my
code?

My code looks something like this :
Dim somethings
result = MsgBox(MsgText.ToString, MsgBoxStyle.YesNo +
MsgBoxStyle.MsgBoxSetForeground, "title")

If result = vbYes Then
start execution
Else
some code
End If

--
regards,

Arvid

Mar 22 '07 #5

What do you have behind the MsgBox?
What do you mean?
I have a page where you have to give a month (text box) and select a value
from a listbox.
The messagebox shows in its text both values and asks for confirmation
(that's what i would like it to do)
You can eather cancel it and nothing happens or click ok and execution
begins for the values selected.

Are you using Javascript in another routine?
No
There is no ASP.Net intrinsic control like this - however there is a
ConfirmButton in the Ajax toolkit.
Is this a tool that you just install and use?
Mar 22 '07 #6
"Aidy" wrote:
How is it done?

You don't. If you want user interaction it has to be done via javascript on
the client, not server-side code. If you use message boxes in asp.net code
the box appears on the server and no-one is there to click it, certainly not
the intented client.
Yes i already know that i cannot use "msgbox" but the above question was how
can i let the user confirm it.

The messagebox text is assembled by input the user gave. The user should
confirm first before a calculation begins

Mar 22 '07 #7
re:
!>There is no ASP.Net intrinsic control like this - however there is a
!>ConfirmButton in the Ajax toolkit.

!Is this a tool that you just install and use?

Pick up ASP.NET Ajax, Ajax extensions and the tookit at :

http://ajax.asp.net/downloads/default.aspx?tabid=47

ASP.NET Ajax general info and instructional videos are at :

http://ajax.asp.net/default.aspx?tabid=47


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
>
>What do you have behind the MsgBox?

What do you mean?
I have a page where you have to give a month (text box) and select a value
from a listbox.
The messagebox shows in its text both values and asks for confirmation
(that's what i would like it to do)
You can eather cancel it and nothing happens or click ok and execution
begins for the values selected.

>Are you using Javascript in another routine?

No
>There is no ASP.Net intrinsic control like this - however there is a
ConfirmButton in the Ajax toolkit.

Is this a tool that you just install and use?

Mar 22 '07 #8
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:3B**********************************@microsof t.com...
How is it done?

You don't. If you want user interaction it has to be done via javascript
on
the client, not server-side code. If you use message boxes in asp.net
code
the box appears on the server and no-one is there to click it, certainly
not
the intented client.

Yes i already know that i cannot use "msgbox" but the above question was
how
can i let the user confirm it.
<script type="text/javascript">

function confirmCalc()
{
return confirm('Are you sure you want to run this calculation?');
}

</script>

Eliyahu has already given you a link to a site which explains how to use
this...
Mar 22 '07 #9
Use a javascript function. I believe it is called Confirm, it pops up a
Yes/No type box, and if the user clicks Yes you submit the form, if they
click No you don't.

"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:3B**********************************@microsof t.com...
"Aidy" wrote:
How is it done?

You don't. If you want user interaction it has to be done via javascript
on
the client, not server-side code. If you use message boxes in asp.net
code
the box appears on the server and no-one is there to click it, certainly
not
the intented client.

Yes i already know that i cannot use "msgbox" but the above question was
how
can i let the user confirm it.

The messagebox text is assembled by input the user gave. The user should
confirm first before a calculation begins

Mar 22 '07 #10
Here's some server side code that uses JavaScript to display a confirmation
message.

MyDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

Here's a more detailed analysis of your options, including a free control
that can handle many of the options for you.
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
Hi,

I made a small ASP.net web page and in it I used a messagebox to confirm
first before an execution would take place.
It worked fine while testing it locally, but when i published it on a
server
it didn't work anymore.

I understand why, but still have the problem that I would like the user to
confirm first before execution begins.

How is it done?
I searched a bit and found javascript solution but how do I fit them in my
code?

My code looks something like this :
Dim somethings
result = MsgBox(MsgText.ToString, MsgBoxStyle.YesNo +
MsgBoxStyle.MsgBoxSetForeground, "title")

If result = vbYes Then
start execution
Else
some code
End If

--
regards,

Arvid
Mar 22 '07 #11
I see that kind of code a lot, personally I would recommend against it. Why
put client-side code in your code behind? Changing it requires a re-compile
and re-release. Just put the code direct in the HTML.

"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:B0**********************************@microsof t.com...
Here's some server side code that uses JavaScript to display a
confirmation message.

MyDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called
in
response to the button click.

Here's a more detailed analysis of your options, including a free control
that can handle many of the options for you.
http://SteveOrr.net/articles/ClientSideSuite.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Arvid" <Ar***@discussions.microsoft.comwrote in message
news:96**********************************@microsof t.com...
>Hi,

I made a small ASP.net web page and in it I used a messagebox to confirm
first before an execution would take place.
It worked fine while testing it locally, but when i published it on a
server
it didn't work anymore.

I understand why, but still have the problem that I would like the user
to
confirm first before execution begins.

How is it done?
I searched a bit and found javascript solution but how do I fit them in
my
code?

My code looks something like this :
Dim somethings
result = MsgBox(MsgText.ToString, MsgBoxStyle.YesNo +
MsgBoxStyle.MsgBoxSetForeground, "title")

If result = vbYes Then
start execution
Else
some code
End If

--
regards,

Arvid

Mar 23 '07 #12
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:ab******************************@bt.com...
>I see that kind of code a lot, personally I would recommend against it.
Why put client-side code in your code behind? Changing it requires a
re-compile and re-release. Just put the code direct in the HTML.
I disagree entirely!!! You're not seriously suggesting that the ability to
hack about with aspx files just because they're not compiled is actually a
"good thing"...?

Projects without proper change control procedures are doomed to failure,
IMO...
Mar 23 '07 #13
"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <St***@Orr.netwrote in
message news:B0**********************************@microsof t.com...
Here's some server side code that uses JavaScript to display a
confirmation message.

MyDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")
And just to add to this, in ASP.NET 2 buttons have an OnClientClick
property:

MyDeleteButton.OnClientClick = ""return confirm('Are you sure you want to
delete?');";
Mar 23 '07 #14
I disagree entirely!!! You're not seriously suggesting that the ability to
hack about with aspx files just because they're not compiled is actually a
"good thing"...?
Yes, yes I am.

Compare changing an aspx file and uploading vs changing a cs file,
re-compiling, re-uploading and resetting the application and booting
everyone off.
Mar 23 '07 #15
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:A5******************************@bt.com...
>I disagree entirely!!! You're not seriously suggesting that the ability
to hack about with aspx files just because they're not compiled is
actually a "good thing"...?

Yes, yes I am.
Wow! What a pro...:-)
Mar 23 '07 #16
Wow! What a pro...:-)

*shrug* I'm a realist and a purist. Client code should go on the client.
Mar 23 '07 #17
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:_b******************************@bt.com...
Client code should go on the client.
??? Where else would it go...??? It could hardly go anywhere else, could
it...!
Mar 23 '07 #18
Ok, client code should be entered at the client level.

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:Oy**************@TK2MSFTNGP02.phx.gbl...
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:_b******************************@bt.com...
>Client code should go on the client.

??? Where else would it go...??? It could hardly go anywhere else, could
it...!

Mar 23 '07 #19
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:BO******************************@bt.com...
Ok, client code should be entered at the client level.
Where the client code is entered is totally and utterly irrelevant as far as
the browser is concerned - my point was that you appear to believe that
hacking about with aspx files is acceptable, and I don't...

No biggie... :-)
Mar 23 '07 #20
my point was that you appear to believe that hacking about with aspx files
is acceptable, and I don't...
What if you need to increase the margin on a DIV or add some extra fields?
Do all of your aspx pages look like this?

<asp:Literal ID="HTMLCodeGoesHere" runat="Server"/>
Mar 23 '07 #21
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:vc*********************@bt.com...
>my point was that you appear to believe that hacking about with aspx
files is acceptable, and I don't...

What if you need to increase the margin on a DIV or add some extra fields?
I make any and all modifications as required in the development environment,
rebuild the project and deploy to the test environment. When the testing is
complete, depending on the client, an outage is scheduled and the code is
deployed live. Depending on the size of the project, deployment to live
typically takes around a minute.

What do you do...? Do you just go hacking at the aspx pages on the live
server simply because you can...?
Do all of your aspx pages look like this?

<asp:Literal ID="HTMLCodeGoesHere" runat="Server"/>
??? Of course they don't - what an incredibly strange question...
Mar 23 '07 #22
What do you do...? Do you just go hacking at the aspx pages on the live
server simply because you can...?
For something as minor as an html change? Yeah I do. If, however, you
generate your HTML code from server-side code then, as you say, an outage
and upload needs to occur.
Mar 26 '07 #23
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:Q4******************************@bt.com...
>What do you do...? Do you just go hacking at the aspx pages on the live
server simply because you can...?

For something as minor as an html change? Yeah I do.
As I said before... wow!
Mar 26 '07 #24
As I said before... wow!

*doffs hat*

Maybe one day you'll be as good as me ;)
Mar 26 '07 #25
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:LM*********************@bt.com...
>As I said before... wow!

*doffs hat*

Maybe one day you'll be as good as me ;)
The day I hack about with aspx pages on a live server without proper change
control procedures is the day I'll retire...
Mar 26 '07 #26
The day I hack about with aspx pages on a live server without proper
change control procedures is the day I'll retire...
Who said there were no change control procedures? The day I do something
complicated rather than something simple "just because" is the day I no
longer work in the real world.
Mar 26 '07 #27
You can try this

in visual basic:
Response.Write("<script language ='javascript'>" & "alert('This is the
message');" & "</script>")
Response.End()

in C#
Response.Write("<script language ='javascript'>" + "alert('This is the
message');" + "</script>");
Response.End();

Dont forget to message me on kr******@yahoo.com for more codes

Apr 10 '07 #28
"kshitij kumar" <kshitij ku***@discussions.microsoft.comwrote in message
news:3F**********************************@microsof t.com...
in visual basic:
Response.Write("<script language ='javascript'>" & "alert('This is the
message');" & "</script>")
Response.End()

in C#
Response.Write("<script language ='javascript'>" + "alert('This is the
message');" + "</script>");
Response.End();
Or, if you wanted to use something a little less outdated, you'd use the
ClientScript object...
Apr 10 '07 #29

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Rich Tasker | last post by:
I have a strange situation. A simple call to MessageBox.Show("XXX", "YYY") does not display the message in the messagebox with a visible font. Based on the content of the messagebox, the box...
8
by: Dennis C. Drumm | last post by:
I have ordered the book .NET Framework Solutions, In Search of the Lost Win32 API by John Paul Meuller which I think will help answer some of my questions I have regarding making custom...
2
by: Dennis C. Drumm | last post by:
This is a restatement of an earlier post that evidently wasn't clear. I am building a custom MessageBox dialog that has, among other things, a few new button options (yes to all, no to all, etc.)...
8
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would...
4
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
3
by: Sin | last post by:
I'm currently evaluating VC.NET as the new platform for the company I work for and things are looking grim... We're up against another IDE which took me about 5 minutes to master and I've been...
0
by: alex_f_il | last post by:
The class centers MessageBox inside the parent rectangle. Enjoy! using System; using System.Windows.Forms; using System.Text; using System.Drawing; using System.Runtime.InteropServices; ...
20
by: Peter E. Granger | last post by:
I'm having a strange problem (or at least it seems strange to me) trying to display a MessageBox in a VC++ .NET forms application. If I put the call to MessageBox::Show in the form's .h file, it...
10
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
4
by: Larry Woods | last post by:
I have a Messagebox that looks like: MessageBox.Show("There are pending changes for this patient. Do you want to continue to close?", "Pending Changes", MessageBoxButtons.YesNo,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.