943,722 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1764
  • ASP.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 29th, 2009
0

Can I use Msgbox function in ASP.NET ?

Expand Post »
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..
Reputation Points: 8
Solved Threads: 1
Light Poster
mania_comp is offline Offline
44 posts
since Jul 2009
Aug 29th, 2009
0

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

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
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 29th, 2009
0

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

Actually here is an example with an alert on a server side control. This will cause an alert then a postback:

Page:
ASP.NET Syntax (Toggle Plain Text)
  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:
ASP.NET Syntax (Toggle Plain Text)
  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. }
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 30th, 2009
0

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

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?
Reputation Points: 8
Solved Threads: 1
Light Poster
mania_comp is offline Offline
44 posts
since Jul 2009
Aug 30th, 2009
0

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

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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sandeep_1987 is offline Offline
17 posts
since Aug 2009
Aug 30th, 2009
0

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

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?
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 30th, 2009
0

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

Click to Expand / Collapse  Quote originally posted by mania_comp ...
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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Aug 31st, 2009
0

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

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..
Reputation Points: 28
Solved Threads: 106
Banned
dnanetwork is offline Offline
633 posts
since May 2008
Aug 31st, 2009
0

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

'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
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Aug 31st, 2009
0

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

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?
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Dropdownlist_SelectedIndexChanged
Next Thread in ASP.NET Forum Timeline: what is the code to perform signout in C#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC