1,105,384 Community Members

how to show message box in ASP.NET using VB

Member Avatar
sreein1986
Posting Whiz
306 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 33 [?]
Skill Endorsements: 2 [?]
 
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

Member Avatar
sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

You can use MsgBox -- just like in VB6.

Member Avatar
Kusno
Junior Poster
191 posts since Aug 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Kusno
Junior Poster
191 posts since Aug 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
sreein1986
Posting Whiz
306 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 33 [?]
Skill Endorsements: 2 [?]
 
0
 

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

Question Answered as of 5 Years Ago by Kusno and sierrainfo
Member Avatar
jbarman
Newbie Poster
1 post since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Thanks!

Member Avatar
PKOLB
Newbie Poster
1 post since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

This was exactly what I needed. Thank you.

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