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,038

HOME > .NET Framework > Forum > (C#) MessageBox.Show ใช้กับ Web form ไม่ได้หรอครับ ? --ต้อง using อะไรก่อนครับ


 

[.NET] (C#) MessageBox.Show ใช้กับ Web form ไม่ได้หรอครับ ? --ต้อง using อะไรก่อนครับ

 
Topic : 050611



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

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

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



พิมพ์ MessageBox ก็ไม่มี auto complete ขึ้น แปลว่ามันใช้ไม่ได้หรือ ต้อง using อะไรก่อนครับ



Tag : .NET, Web (ASP.NET), C#

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-10-22 11:51:04 By : zixsenz View : 11201 Reply : 14
 

 

No. 1



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

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

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

มันมีนะครับ แต่ไม่รู้ว่ามันแล้วแต่เหตุการณ์ที่จะใช้หรือป่าว บางทีพิมพ์ msgbox.show ก็ขึ้น บางครั้งก็ต้องพิมพ์ messagebox.show
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 11:54:40 By : Dragons_first
 

 

No. 2



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

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

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

Confirm (VB.NET)
1.If MessageBox.Show("Are you sure to exit?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
2.    Application.Exit()
3.End If


Message Box (VB.NET)
1.MessageBox.Show("Please input (Name)")

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 12:01:07 By : webmaster
 

 

No. 3



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

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

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


ตอบความคิดเห็นที่ : 2 เขียนโดย : webmaster เมื่อวันที่ 2010-10-22 12:01:07
รายละเอียดของการตอบ ::
.ของผม C# อ่ะครับ

แล้วก็ มันไม่ขึ้นเลยครับ ทั้ง MessageBox ทั้ง MsgBox -*-

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 12:23:26 By : zixsenz
 

 

No. 4

Guest


MessageBox.cs
01.using System;
02.using System.Data;
03.using System.Configuration;
04.using System.Web;
05.using System.Web.Security;
06.using System.Web.UI;
07.using System.Web.UI.WebControls;
08.using System.Web.UI.WebControls.WebParts;
09.using System.Web.UI.HtmlControls;
10. 
11.using System.Collections;
12.using System.Text;
13. 
14./// <summary>
15./// Summary description for MessageBox
16./// </summary>
17.public class MessageBox
18.{
19.    private static Hashtable m_executingPages = new Hashtable();
20.     
21.    public MessageBox()
22.    {
23.        //
24.        // TODO: Add constructor logic here
25.        //
26.    }
27.  
28.    public static void Show(string sMessage)
29.    {
30.        // If this is the first time a page has called this method then
31.        if(!m_executingPages.Contains(HttpContext.Current.Handler))
32.        {
33.            // Attempt to cast HttpHandler as a Page.
34.            Page executingPage = HttpContext.Current.Handler as Page;
35. 
36.            if(executingPage != null)
37.            {
38.                // Create a Queue to hold one or more messages.
39.                Queue messageQueue = new Queue();
40.                // Add our message to the Queue
41.                messageQueue.Enqueue(sMessage);
42.                // Add our message queue to the hash table. Use our page reference
43.                // (IHttpHandler) as the key.
44.                m_executingPages.Add(HttpContext.Current.Handler, messageQueue);
45.                // Wire up Unload event so that we can inject
46.                // some JavaScript for the alerts.
47.                executingPage.Unload += new EventHandler(ExecutingPage_Unload);
48.            
49.        }
50.        else
51.        {
52.            // If were here then the method has allready been
53.            // called from the executing Page.
54.            // We have allready created a message queue and stored a
55.            // reference to it in our hastable.
56.            Queue queue = (Queue) m_executingPages[HttpContext.Current.Handler];
57.            // Add our message to the Queue
58.            queue.Enqueue(sMessage);
59.        }
60.    }
61. 
62.    // Our page has finished rendering so lets output the
63.    // JavaScript to produce the alert's
64.    private static void ExecutingPage_Unload(object sender, EventArgs e)
65.    {
66.        // Get our message queue from the hashtable
67.        Queue queue = (Queue) m_executingPages[HttpContext.Current.Handler];
68. 
69.        if(queue != null)
70.        {
71.            StringBuilder sb = new StringBuilder();
72.            // How many messages have been registered?
73.            int iMsgCount = queue.Count;
74.            // Use StringBuilder to build up our client slide JavaScript.
75.            sb.Append("<script language='javascript'>");
76.            // Loop round registered messages
77.            string sMsg;
78. 
79.            while(iMsgCount-- > 0)
80.            {
81.                sMsg = (string) queue.Dequeue();
82.                sMsg = sMsg.Replace( "\n", "\\n" );
83.                sMsg = sMsg.Replace( "\"", "'" );
84.                sb.Append( @"alert( """ + sMsg + @""" );" );
85.            }
86.            // Close our JS
87.            sb.Append(@"</script>");
88.            // Were done, so remove our page reference from the hashtable
89.            m_executingPages.Remove(HttpContext.Current.Handler);
90.            // Write the JavaScript to the end of the response stream.
91.            HttpContext.Current.Response.Write(sb.ToString());
92.        }
93.    }
94.}


คลิกขวาที่ folder app_code แล้ว add new item เป็น class แล้วก็อปด้านบนไปใส่

ไปปลูกผักต่อแล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 12:50:07 By : ตังค์แมน
 

 

No. 5



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

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

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


โห

สรุปคือแค่ MessageBox นี่ C# ต้องเขียน class ขึ้นมาเองเลยหรอครับ ><
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 13:17:31 By : zixsenz
 

 

No. 6



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



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


จริงแล้วใช้ MsgBox.Show ก็ได้เหมือนกันครับ แต่ที่ไม่ขึ้นี้ผมว่า คุณเขียนยังไงถึงไม่ขึ้นมากกว่า
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 13:24:53 By : kanchen
 

 

No. 8



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

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

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


ตอบความคิดเห็นที่ : 6 เขียนโดย : kanchen เมื่อวันที่ 2010-10-22 13:24:53
รายละเอียดของการตอบ ::
จริงแล้วใช้ MsgBox.Show ก็ได้เหมือนกันครับ แต่ที่ไม่ขึ้นี้ผมว่า คุณเขียนยังไงถึงไม่ขึ้นมากกว่า


ไม่ได้อ่ะครับ

เท่าที่หาๆดู Code C# ที่อยู่ดีๆจะมาใช้ MsgBox เลยไม่ได้ครับ ต้องเขียนฟังก์ชันขึ้นมาเอง แล้วถึงเรียกใช้

ไม่ก็ใช้ writeline javascript alert เอา
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 15:14:49 By : zixsenz
 

 

No. 9



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



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


ถูกครับ VS(C#) บางตัวจะไม่มี MsgBox ให้เรียกใช้งาน

ลองค้นหากระทู้เก่าๆดูครับ อาจมีคำตอบให้คุณได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 16:45:49 By : 3rds
 

 

No. 10

Guest


ใช้ javascript ดีกว่านะครับ
Response.Write("<script type="text/javascript">alert('test');</script>");
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 18:53:56 By : เราเอง
 

 

No. 11



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

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

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


ตอบความคิดเห็นที่ : 5 เขียนโดย : zixsenz เมื่อวันที่ 2010-10-22 13:17:31
รายละเอียดของการตอบ ::
เขียนด้วย javascript ก็ได้ แต่ตรงไป regidter start up script อะไรวุ่นวายอีก

ทำเป็น class ไว้แหละ เวลาเวลาใช้ก็แค่ MessageBox.Show("xxx"); จะใช้ตรงไหนก็ได้

แล้วตอนใช้ก็ให้ความรู้สึกเหมือนเขียน win app ด้วย



ประวัติการแก้ไข
2010-10-22 19:25:57
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-22 19:25:08 By : tungman
 

 

No. 12



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



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

เขียน MSG บน webform ไม่เหมือนเขียนบน windown form น่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-09-30 11:37:45 By : Noomyontrakit
 

 

No. 13

Guest


ตอบความคิดเห็นที่ : 4 เขียนโดย : ตังค์แมน เมื่อวันที่ 2010-10-22 12:50:07
รายละเอียดของการตอบ ::
ผมทำตามนี้แล้วก็สามารถใช้ คำสั่งmessageboxได้ แต่ทำได้แค่ messagebox.Show("text"); อะคับ


ยังไม่สามารถใช้ คำสั่ง If MessageBox.Show("Are you sure to exit?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
Application.Exit() ได้เลย ไม่ทราบว่าทำอย่างไรดีครับ มือใหม่ช่วยดีครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-11-13 22:07:33 By : mrkrittin
 

 

No. 14

Guest


Code (C#)
1.lberror.Text = "กรุณาตรวจสอบข้อมูล";
2.                    lberror.Visible = true;

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-04-18 16:42:45 By : a
 

 

No. 15

Guest


ฮ่วย มันจะไปเหมือน msg ของ win form ได้ไงเล่า

class นี้ทำให้สามารถใช้ javascript alert message แบบง่ายๆ โดยไม่ต้องไปเขียน javascipt ยาวๆ

โดยให้วิธีการใช้งานคล้ายๆ ของ win form แค่นั้นแหละ โดยความสามารถก็แค่ alert message

เช่น

Code (C#)
1.protected void Button1_Click(object sender, EventArgs e)
2.{
3.   MessageBox.Show("แสดง alert");
4.}



ไม่ถึงกับเหมือน messagebox จริงๆ หรอก ถ้าจะให้ได้แบบนั้นต้องใช้ popup model แล้ว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-06 14:16:19 By : ห้ามตอบเกินวันละ 2 กระทู้
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : (C#) MessageBox.Show ใช้กับ Web form ไม่ได้หรอครับ ? --ต้อง using อะไรก่อนครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





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