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

Recommended Answers

All 7 Replies

You can use MsgBox -- just like in VB6.

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.

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

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.

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

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

Thanks!

This was exactly what I needed. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.