1.11M Members

how to show message box in ASP.NET using VB

 
0
 

I have a doubt in asp.net i created one form in ASP.NET using VB in that how to show message box after clicking a button

 
0
 

You can use MsgBox -- just like in VB6.

 
0
 

You can use MsgBox -- just like in VB6.

CMIIW : It's only work in Microsoft Visual Studio Designer, not in IIS.

I searched in Google how to create Msgbox and I found it.

Public Sub UserMsgBox(ByVal F As Object, ByVal sMsg As String)
        Dim sb As New StringBuilder()
        Dim oFormObject As System.Web.UI.Control = Nothing
        Try
            sMsg = sMsg.Replace("'", "\'")
            sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
            sMsg = sMsg.Replace(vbCrLf, "\n")
            sMsg = "<script language='javascript'>alert('" & sMsg & "');</script>"
            sb = New StringBuilder()
            sb.Append(sMsg)
            For Each oFormObject In F.Controls
                If TypeOf oFormObject Is HtmlForm Then
                    Exit For
                End If
            Next
            oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(sb.ToString()))
        Catch ex As Exception

        End Try
    End Sub

Protected Sub CmdPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdPrint.Click
         If CmbCCY.SelectedIndex <= 0 Then
            UserMsgBox(Me, "Currency ID is not Selected.")
            CmbCCY.Focus()
            Exit Sub
        End If 
End Sub

Thank,

Kusno.

 
0
 

You have to configure IIS to support ASP.Net for the Msgbox code to work. Is your IIS configured for ASP.Net?

 
0
 

You have to configure IIS to support ASP.Net for the Msgbox code to work. Is your IIS configured for ASP.Net?

As far as I know, MsgBox is located in System.Windows namespace, but ASP.Net is located in System.Web namespace. So the environment is different.
But, If you could run it, please show to me how to configure your IIS.

Thanks,

Kusno.

 
0
 

i got the answer
thanks for all to give your replies ...

Question Answered as of 6 Years Ago by Kusno and sierrainfo
 
0
 

I found this thread to be extreamly helpful! It worked perfectly in my program!

Thanks!

 
0
 

This was exactly what I needed. Thank you.

Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article