how to show message box in ASP.NET using VB
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
11 Months Ago
Last Updated
sreein1986
Posting Whiz
306 posts since May 2008
Reputation Points: 12
Solved Threads: 34
Skill Endorsements: 1
You can use MsgBox -- just like in VB6.
sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
Skill Endorsements: 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.
Kusno
Junior Poster
191 posts since Aug 2007
Reputation Points: 11
Solved Threads: 17
Skill Endorsements: 0
You have to configure IIS to support ASP.Net for the Msgbox code to work. Is your IIS configured for ASP.Net?
sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
Skill Endorsements: 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.
Kusno
Junior Poster
191 posts since Aug 2007
Reputation Points: 11
Solved Threads: 17
Skill Endorsements: 0
i got the answer
thanks for all to give your replies ...
sreein1986
Posting Whiz
306 posts since May 2008
Reputation Points: 12
Solved Threads: 34
Skill Endorsements: 1
Question Answered as of 4 Years Ago by
sierrainfo
and
Kusno I found this thread to be extreamly helpful! It worked perfectly in my program!
Thanks!
jbarman
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
This was exactly what I needed. Thank you.
PKOLB
Newbie Poster
1 post since Jul 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0