Can I use Msgbox function in ASP.NET ?

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2009
Posts: 41
Reputation: mania_comp is an unknown quantity at this point 
Solved Threads: 1
mania_comp mania_comp is offline Offline
Light Poster

Can I use Msgbox function in ASP.NET ?

 
0
  #1
Aug 29th, 2009
hi guys

I have heard that for displaying message we generally use MSGBOX function in VB.NET and
we use ScriptManager.RegisterStartscript in ASP.NET to display message box...
but I have tried to use Msgbox function in ASP.NET and it works here also...
So is it ok to use Msgbox function in websites to display message or
there are some problems or issues related to it?

If yes then pls let me know..
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,210
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #2
Aug 29th, 2009
No you can't. You need to use a client side alert() with javascript. You can read about client side events here:
http://www.eggheadcafe.com/articles/20041016.asp
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,210
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #3
Aug 29th, 2009
Actually here is an example with an alert on a server side control. This will cause an alert then a postback:

Page:
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Alerter.aspx.cs" Inherits="daniweb.web.Alerter" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <title></title>
  6. </head>
  7. <body>
  8. <form id="form1" runat="server">
  9. <div>
  10. <asp:Button ID="Button1" runat="server" Text="Button" />
  11. </div>
  12. </form>
  13. </body>
  14. </html>

Code behind:
  1. using System;
  2.  
  3. namespace daniweb.web
  4. {
  5. public partial class Alerter : System.Web.UI.Page
  6. {
  7. protected void Page_Load(object sender, EventArgs e)
  8. {
  9. Button1.Attributes.Add("onclick", "javascript:alert('hello');");
  10. }
  11. }
  12. }
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: mania_comp is an unknown quantity at this point 
Solved Threads: 1
mania_comp mania_comp is offline Offline
Light Poster

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #4
Aug 30th, 2009
ya i know that we should use alert function to display client side script in asp.net
but
i have msgbox function in my website and when I RUN the webpage it gives no error ..it works fine... ..
I want to know will that will it problems in real time deployment..??
I my PC that page runs well with MSGBOX function... but will it cause problems in realtime when website will be deployed to SERVER?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 17
Reputation: sandeep_1987 is an unknown quantity at this point 
Solved Threads: 0
sandeep_1987 sandeep_1987 is offline Offline
Newbie Poster

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #5
Aug 30th, 2009
hey sknake,can u tell me one thing,that instead of writing Button1.Attributes.Add("onclick", "javascript:alert('hello');"); on button click event,Y we write it in Page Load event!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,210
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #6
Aug 30th, 2009
Originally Posted by sandeep_1987 View Post
hey sknake,can u tell me one thing,that instead of writing Button1.Attributes.Add("onclick", "javascript:alert('hello');"); on button click event,Y we write it in Page Load event!
What?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,210
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #7
Aug 30th, 2009
Originally Posted by mania_comp View Post
ya i know that we should use alert function to display client side script in asp.net
but
i have msgbox function in my website and when I RUN the webpage it gives no error ..it works fine... ..
I want to know will that will it problems in real time deployment..??
I my PC that page runs well with MSGBOX function... but will it cause problems in realtime when website will be deployed to SERVER?
I don't know the answer to that -- go ahead and test it out. The MsgBox() call lies in the System.VisualBasic namespace and I do my best to avoid that namespace for compatibility reasons.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 164
Reputation: dnanetwork has a little shameless behaviour in the past 
Solved Threads: 24
dnanetwork's Avatar
dnanetwork dnanetwork is offline Offline
Junior Poster

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #8
Aug 31st, 2009
i agree with snake...

but i'm curious why do u need a feature like MessageBox..?

or there is another way but it's a long way..
Mark the thread as resolved if your problem gets resolved :)
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 136
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #9
Aug 31st, 2009
'hey sknake,can u tell me one thing,that instead of writing Button1.Attributes.Add("onclick", "javascript:alert('hello');"); on button click event,Y we write it in Page Load event! '

This is used in the form load so that the Javascript is applied to the control once the form loads, otherwise this will only be applied to the control once you click on a button , therefore you will have to click the button twice.

1. to apply the JavaScript
2. to fire the javaScript
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,210
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Can I use Msgbox function in ASP.NET ?

 
0
  #10
Aug 31st, 2009
The form_load event fires server side to create the page -- not when the form loads at the browser end. Its just adding a client side event to the button -- the asp:button's click event is normally server side.

Is this what you are asking?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC