Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,028

HOME > .NET Framework > Forum > รบกวนคุณ tungman หน่อยครับ ถามเรื่อง MessageBox ของ ASP.net ครับ



 

รบกวนคุณ tungman หน่อยครับ ถามเรื่อง MessageBox ของ ASP.net ครับ

 



Topic : 049573



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์




อันนี้ Code ที่พี่เคยให้มาครับ จะทำให้ Asp.net สามารถใช้ MessageBox ได้
แต่มันไม่สามารถสร้างรูปแบบ แบบมี ปุ่ม OK.Cancel หรือ Yes, no ได้อ่ะครับ
ไม่ทราบว่า Asp.net สามารถใช้ MessageBox แบบ มีปุ่ม OK.Cancel หรือ Yes, no ได้ไหมครับ

ขอบคุณครับ

Code (VB.NET)
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Imports System.Collections
Imports System.Text

''' <summary>
''' Summary description for MessageBox
''' </summary>
Public Class MessageBox
	Private Shared m_executingPages As New Hashtable()

			'
			' TODO: Add constructor logic here
			'
	Public Sub New()
	End Sub

	Public Shared Sub Show(sMessage As String)
		' If this is the first time a page has called this method then
		If Not m_executingPages.Contains(HttpContext.Current.Handler) Then
			' Attempt to cast HttpHandler as a Page.
			Dim executingPage As Page = TryCast(HttpContext.Current.Handler, Page)

			If executingPage IsNot Nothing Then
				' Create a Queue to hold one or more messages.
				Dim messageQueue As New Queue()
				' Add our message to the Queue
				messageQueue.Enqueue(sMessage)
				' Add our message queue to the hash table. Use our page reference
				' (IHttpHandler) as the key.
				m_executingPages.Add(HttpContext.Current.Handler, messageQueue)
				' Wire up Unload event so that we can inject
				' some JavaScript for the alerts.
				AddHandler executingPage.Unload, New EventHandler(AddressOf ExecutingPage_Unload)
			End If
		Else
			' If were here then the method has allready been
			' called from the executing Page.
			' We have allready created a message queue and stored a
			' reference to it in our hastable.
			Dim queue As Queue = DirectCast(m_executingPages(HttpContext.Current.Handler), Queue)
			' Add our message to the Queue
			queue.Enqueue(sMessage)
		End If
	End Sub

	' Our page has finished rendering so lets output the
	' JavaScript to produce the alert's
	Private Shared Sub ExecutingPage_Unload(sender As Object, e As EventArgs)
		' Get our message queue from the hashtable
		Dim queue As Queue = DirectCast(m_executingPages(HttpContext.Current.Handler), Queue)

		If queue IsNot Nothing Then
			Dim sb As New StringBuilder()
			' How many messages have been registered?
			Dim iMsgCount As Integer = queue.Count
			' Use StringBuilder to build up our client slide JavaScript.
			sb.Append("<script language='javascript'>")
			' Loop round registered messages
			Dim sMsg As String

			While System.Math.Max(System.Threading.Interlocked.Decrement(iMsgCount),iMsgCount + 1) > 0
				sMsg = DirectCast(queue.Dequeue(), String)
				sMsg = sMsg.Replace(vbLf, "\n")
				sMsg = sMsg.Replace("""", "'")
				sb.Append("alert( """ & sMsg & """ );")
			End While
			' Close our JS
			sb.Append("</script>")
			' Were done, so remove our page reference from the hashtable
			m_executingPages.Remove(HttpContext.Current.Handler)
			' Write the JavaScript to the end of the response stream.
			HttpContext.Current.Response.Write(sb.ToString())
		End If
	End Sub
End Class





Tag : .NET, Web (ASP.NET), VB.NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-09-30 16:54:03 By : ang89gunner View : 3129 Reply : 6
 

 

No. 1



โพสกระทู้ ( 183 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
 If MsgBox("ยืนยันมั้ยจ๊ะ?", MsgBoxStyle.OkCancel, "ยืนยันหน่อย") = MsgBoxResult.Ok Then
         MsgBox("คุณตกลงแล้ว")
 End If







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-30 17:00:10 By : 3rds
 


 

No. 2



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


แฮะๆๆ ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-30 22:15:13 By : ang89gunner
 

 

No. 3



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


ผมลองตามนี้ แล้ว พอกด ปุ๋มมันจะขึ้นกล่องข้อความมาให้ยืนยัน OK กับ Cancel 2 รอบอ่ะครับ

Code (VB.NET)
  Protected Sub btnDelete_Click
strSQL = "DELETE FROM [Member] WHERE [UserID] = @UserID"
        objCmd = New SqlCommand(strSQL, objConn)
        objCmd.Parameters.AddWithValue("@USerID", Me.lbluserid.Text)
        If MsgBox("คุณต้องการลบ Record?", MsgBoxStyle.OkCancel, "ยืนยันหน่อย") = MsgBoxResult.Ok Then
            Try
                If objConn.State = ConnectionState.Open Then
                    objConn.Close()
                End If
objConn.Open()
                objCmd.ExecuteNonQuery()
                objConn.Close()

                Me.lblStatus.Text = "Record DELETE"
                Me.lblStatus.Visible = True
                GridView1.DataBind()
                ClearValule()
            Catch ex As Exception
                Me.lblStatus.Text = "Record can not DELETE. Because: " & ex.Message
            End Try
Else
Exit Sub
        End If
        
    End Sub

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-30 23:04:05 By : ang89gunner
 


 

No. 4



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


Code (VB.NET)
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="javascript:return confirm('tungman');" />


Code (VB.NET)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
     MessageBox.Show("tungtungtungtung")
End Sub

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-30 23:15:57 By : tungman
 


 

No. 5



โพสกระทู้ ( 96 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณ มากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-09-30 23:36:29 By : ang89gunner
 


 

No. 6



โพสกระทู้ ( 245 )
บทความ ( 0 )



สถานะออฟไลน์


ผมลองใช้ MsgBox("alerttest",MsgBoxStyle.OkOnly,"test") พอPublish แล้วเกิด Error น่ะครับ

เลยเปลี่ยนไปใช้ Class ของพี่แพนด้าแทน สามารถใช้งานได้ครับ

แต่ติดนิดเดียว คือ ถ้ามี Response.Redirect อยู่บรรทัดต่อไป มันจะ Redirect เลยโดยที่ไม่ต้องรอกด ตกลงเลยน่ะครับ

ไม่ทราบว่าจะแก้ยังไงดี
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-11-04 08:54:15 By : 13crowns
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนคุณ tungman หน่อยครับ ถามเรื่อง MessageBox ของ ASP.net ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่