Unable to display Message Box in ASP.NET using VB.NET
The MessageBox class is a class that displays a MessageBox on the machine on
which the application is running. An ASP.Net application runs on a server, When moving from Windows Forms to ASP.NET Web Forms, an API that may be missed is that offered by the System.Windows.Forms.MessageBox Class. How do i create one form in ASP.NET using VB in that how to show message box after clicking a button. In order to alert the user we need to inject some client side code into the HTML page. This is a simple task but can become quite a nuisance if this functionality is required on a regular basis.
Re: Unable to display Message Box in ASP.NET using VB.NET
The code which you will be created that you need to added to the HTML of the page sent to the client. You could add such a script using.
Page.RegisterStartupScript(). Example:
Dim strScript As String
strScript = "<script type=""text/javascript"">alert('This is the testing application')</script>"
If Not Page.IsStartupScriptRegistered("MyScript") Then
Page.RegisterStartupScript("MyScript", strScript)
End If
This is the reason why we store the Queue in a Hashtable, because we are using static methods. There is the potential for multiple pages to be using the class at the same time (on separate threads).
Re: Unable to display Message Box in ASP.NET using VB.NET
MsgBox is located in System.Windows namespace, but ASP.Net is located in System.Web namespace.There is the potential for multiple pages to be using the class at the same time (on separate threads). So the environment will be different. But, If you could run it, please show to me how to configure your IIS.Forms namespace is usable only from Windows Forms and NOT ASP.NET Web Forms. In order to alert the user we need to inject some client side code into the HTML page.
Re: Unable to display Message Box in ASP.NET using VB.NET
Using JavaScript, you can access the dialog boxes while on page loading or after rendering the page content to the browser. There is no way to get a confirmation from the user while you process the functionality through JavaScript. To accomplish this you have to go for a server side message box.
The following code will allow you to create web form code behind, add the following line of code:
In VB.NET
Code:
Imports NewMsgBoxAsp.Holool.Anwar.Web.Controls.UI
The following line Creates an instance of MessageBox class, to access its properties and methods:
VB.NET
Code:
Dim NBox As MessageBox = New MessageBox
Re: Unable to display Message Box in ASP.NET using VB.NET
'ASP.net MessageBox
'Add a scriptmanager to the ASP.Net Page
<asp:scriptmanager id="ScriptManager1" runat="server" />
try:
Dim sMsg As String = "My Message"
ScriptManager.RegisterStartupScript(Page, Page.GetType, Guid.NewGuid().ToString(), "alert('" & sMsg & "')", True)